Removing a Component That's Not There

  • Thread starter Thread starter C Glenn
  • Start date Start date
C

C Glenn

I've recompiled a DLL that contains a component. The component vanished
from the form. I've since tried to replace it but most of the code
associated with the component remained in the cs. The code editor
naturally complained that I was duplicating a name. (The portion of the
code that was removed was the line that instantiated the component.)

Can I get back the visual aspect of the component? If not, how can I
alter the code in the area where I'm told not to go. (I've had retched
experience with that and don't want to repeat it.)
 
haha
i have ran in to these sorts of problems so many times. pain i tell u

What i have done is that i would simply go to the code view
go to the section called "windows form designer generated code"
find the code for the component you are missing (visually) cut the code out.
then go to the designer put that component back rename it to what the
previous was called
then go back to where you cut the code from, find the code for the new
componenet (the one u just added)
and replace that code with the previous code.

Next time this happends what you do is not close any file but go to the code
and press control z (undo) until this
message saying blah blah blah " are you sure" press yes. this will get your
component back.

This mostly happends because you have some sort of error somewhere in your
code. many times if your close the designer,
recompile the program it works. but many time it does not

hth

raj
 
Thanks. The 'undo' idea was one that I hadn't considered. I managed to
un-mangle my mess by using Replace to change all of the new code to
refer to the correct (old) name after removing the old name from the
code. Pretty much as you suggested.

Thanks.
PS: Hey, don't ever make the mistake of editing the 'form designer
generated code' then quickly running your app. I lost all elements of
the form -- every component was removed irretrievably.
 
Back
Top