Form does not refresh in designer when a UserControl is deleted

H

Haiping Jia

Hi,

In our application we use designer to add our own UserControls to a form.
The problem is when we deleted the UserControls we still see them in the form
in desgner. When we save it and reopen the form again the UserControls were
gone. Why form does not refresh itself in designer? How can I make the form
refresh itslef?

Thanks for any suggestions,
 
P

Peter Duniho

Hi,
In our application we use designer to add our own UserControls to a form.
The problem is when we deleted the UserControls we still see them in the
form
in desgner. When we save it and reopen the form again the UserControls
were
gone. Why form does not refresh itself in designer? How can I make the
form
refresh itslef?

IMHO, you ought to delete the controls from the form before you delete the
code for them anyway.

But in any case, the Designer is working from the assembly where the
UserControl code is compiled. You should be seeing the UserControl
objects being removed once that assembly has been compiled, which doesn't
happen automatically after the UserControl has been deleted from the
project.

So, you shouldn't have to close and reopen the project, but at the very
least, you would need to recompile to see the changes.

Pete
 
H

Haiping Jia

Hi Pete,

Thanks for your answer.
I tried your suggestiong: to rebuild after I delete the UserControl from
designer. It was built without any error but I still see the UserControl on
the from. It means the deleting deleted the code but not triggers the form
to refresh itself.

If I add a button or label to the form and delete them from designer I will
see the from refreshs itself immediately . Why the form does not refresh
itself after I delete my user control?

Haiping
 
P

Peter Duniho

Hi Pete,

Thanks for your answer.
I tried your suggestiong: to rebuild after I delete the UserControl from
designer. It was built without any error but I still see the UserControl
on
the from. It means the deleting deleted the code but not triggers the
form
to refresh itself.

If I add a button or label to the form and delete them from designer I
will
see the from refreshs itself immediately . Why the form does not refresh
itself after I delete my user control?

I can't answer the question. My best guess: simply because it can't,
because that's just not how the IDE was written.

You do seem to be comparing apples to oranges. That is, explicitly
deleting a button or label from your form is obviously not the same as
deleting the code that supports the button or label. Instead, it's more
like deleting the UserControl instance itself from the form, and of course
if you do that, it works just like deleting a button or label.

I find it odd that when you actually delete the supporting code for the
UserControl, you are still able to compile successfully. I don't see how
that can work, unless you have some additional step you're not telling us
about (e.g. copying the UserControl's assembly to a directory local to the
project that uses it).

Pete
 
H

Haiping Jia

Hi Peter,

Thanks for your quick response.
Sorry I mean delete my User Control the same way as I delete the buttons or
labels: explicitly deleting my User controls from the form. I don't
understand why deleting button triggers form to refresh but deleting my User
Controls does not.

Haiping
 
P

Peter Duniho

Hi Peter,

Thanks for your quick response.
Sorry I mean delete my User Control the same way as I delete the buttons
or
labels: explicitly deleting my User controls from the form. I don't
understand why deleting button triggers form to refresh but deleting my
User
Controls does not.

Well, that I don't know. I've never seen a problem like that. Any
control on your form, if you select it and then delete it, it should be
removed immediately, whether it's a UserControl or some other type.

If it doesn't work for you, then there's something wrong with your
installation of Visual Studio. What that might, I can't say.

Pete
 
H

Haiping

Hi Peter,
I tried on other people's computer. It has the same problem. So I don't
think there is some thing wrong with the Visual Studio installation. It must
be some thing that related to my user controls. I will keep search.

Thank you,
Haiping
 

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