Problem developing a UserControl

M

MuZZY

Hi,

I just started dealing with user controls and i am getting the following
problem with testing this control:
Basicly i have a solution with two projects: first is the usercontrol
and secont is WinFroms application for testing the control. So what
happens is that once i add the usercontrol to the palette and then add
it to the form, i no longer can recompile the control, because it's dll
file is blocked. Even if i remove the control from the form and from
toolbox, i still can't recompile the dll untill i completely close VS
IDE and reopen it again..

I feel really stupid having to close and reopen VS each time i need to
make a change in the user control code and recompile it. I am sure that
there is a standard way to overgo this annoyance but have no clue so far :(

Could anybody please give me an advise on how to make it proper way?

Thank you in advance,
Andrey
 
S

Sijin Joseph

How are you adding your usercontrol to the toolbox? If you have a
usercontrol project in your application, when you build it in the
Toolbox window "My User Controls" gets automatically populated with an
instance of your usercontrol, you don't have to add anything. Just drag
the control from there to your form and the references will be
automatically setup. Make sure that the reference to your usercontrol
proejct is a "project reference"(Set via the projects tab of "Add
Reference" dialog) and not a "file reference". If you have already set
the reference manually, just delete the reference and use the above
method to add the usercontrol to your form.

Let me know if that helps.


Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
 
M

MuZZY

Sijin said:
How are you adding your usercontrol to the toolbox? If you have a
usercontrol project in your application, when you build it in the
Toolbox window "My User Controls" gets automatically populated with an
instance of your usercontrol, you don't have to add anything. Just drag
the control from there to your form and the references will be
automatically setup. Make sure that the reference to your usercontrol
proejct is a "project reference"(Set via the projects tab of "Add
Reference" dialog) and not a "file reference". If you have already set
the reference manually, just delete the reference and use the above
method to add the usercontrol to your form.

Let me know if that helps.

Thank you Sijin, it works!

But, it doesn't update the user control already residing on the form
when i change it:
say, my control has white background. I put it on the form and it's
white. Now i change control's background to black, recompile both
projects, but the form still shows the component with white background.
But if at this point i add a second instance of the UC to the form, this
one shows with correct color. So it looks wierd - two same components on
the form have diferent color - one black(new) and one white(old).

SO i assume if a change/ add anything else to the UC, it will still be
"old" on the form until i remove it and re-add to the form.

How to update the UC which is already on the form?

Thank you,
Andrey
 
B

Bob Powell [MVP]

I just put an article in Windows Forms Tips and Tricks that explains how you
should go about debugging and testing controls like this.

Just google for "Windows Forms Tips and Tricks" and hit the "I'm feeling
lucky" button.

Go to the Debugging Controls article.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top