views:

57

answers:

3

Anyone faced a problem while creating a UserControl in a library then drop it in a Form project...change this control's e.g. BackColor and rebuilding, changes are not reflecting in the Form project?

EDITED: when updating the control e.g. change controls, drop new controls inside the control, updating is happening. Looks like the controls backcolor stay static, or change only once.

This is so lame, and I'm so tired trying to find what is the problem!

I use VS2010 Ultimate, Windows 7 x64.

I found while dropping the control, adds in the designr initialization about the backcolor. If i delete this it works. How bad is that? It looks like a bug to me? is it?

You can do this only once!

+1  A: 

This is a bug in VS2010.

When you add a custom control to a designer in the same project, VS will add a reference to the project itself.

After adding a control to a designer in the same project, you should delete this reference.

SLaks
Sorry, i don't see any self reference. You mean adding a custom control in same solution but from different project should add a reference from the control's library? if yes this is the right behavior. If you mean something like self referencing, i don't see anything like this, which is kinda impossible to happen!!! edit: Self Referencing not happening according to the url you provided for me.
@gtas: This bug only applies if both the form and the control are in the same project.
SLaks
Tried this too and is working correctly!
No solution yet!
A: 

If the two projects are in the same solution, change the reference to a Project Reference (Add Reference, Projects tab) and try re-building the entire solution.

Otherwise, build the library and the form, in that order.

SLaks
It is a project reference...rebuilding seems to update the bin files in both projects but seems that the changes are not reflecting in the same control library, icant get any other explanation.
@gtas: This is a bug in VS2010. Dropping a control onto a form in the same project adds a reference to the project itself. Delete that reference. http://stackoverflow.com/questions/3001380/visual-studio-adds-a-circular-reference-when-i-drag-and-drop-a-user-control-from
SLaks
+1  A: 

The BackColor property you set in the control designer and the BackColor property you set in the Form designer is the same property, the the one in the control designer acting as the default. The form designer sets it explicitly, yes, so you need to re-set it if you change the default.

You'll find that if you re-add the control, it will have the proper background colour.

To fix it, just change the property in the form to the right colour.

Mike Caron
Yes this is the correct solution. I guess I just waited to reflect the control's default color in the form too. It's much more clear now this behavior.