How to remove automatic generated lines in Form.Designer.cs refering non-existing objects ?

  • Thread starter Thread starter Mark Poppers
  • Start date Start date
M

Mark Poppers

Assume the following sequence of user actions starting with a Form and an e.g. StatusStrip:

1.) User doubleclicks on the StatusStrip
2.) VisualStudio jumps to the new generated source code

mystatusstrip_itemClicked() { ..... }

3.) The user deletes this function from source code (because he decide not to add such an event)
4.) "Rebuild of source code"
5.) An error appears:

mynamespace.Form1 does not contain a defintion for "mystatsustrip_itemClicked"

Obvisouly the DoubleClick inserts not only a function in the user source code but also
a reference in the Form1.Designer code.

How do I let VS 2005 automatically remove (resp. synchronize) not existing
function calls in Form1.Designer code ?

Mark
 
Assume the following sequence of user actions starting with a Form and an e.g. StatusStrip:

1.) User doubleclicks on the StatusStrip
2.) VisualStudio jumps to the new generated source code

mystatusstrip_itemClicked() { ..... }

3.) The user deletes this function from source code (because he decide not to add such an event)
4.) "Rebuild of source code"
5.) An error appears:

mynamespace.Form1 does not contain a defintion for "mystatsustrip_itemClicked"

Obvisouly the DoubleClick inserts not only a function in the user source code but also
a reference in the Form1.Designer code.

How do I let VS 2005 automatically remove (resp. synchronize) not existing
function calls in Form1.Designer code ?

Mark

In the designer right click on the status strip and choose properties.
In the property grid click on the events button (the lightning bolt).
Find the ItemClicked event.
Clear the text from beside it.

Now the form should comile.
 
Hi,

How do I let VS 2005 automatically remove (resp. synchronize) not existing
function calls in Form1.Designer code ?

There is no automatic way that I know of if you just remove the method from
the code.
Under that escenario you have two options:
1- compile the project, it will show the error, you just simply remove the
offending line in the designer.cs code and recompile
2- in the design view, select the control, go to properties, events and
clear the event you do not want to fire.


Now I might be wrong but I'm using Infragistics controls lately and I have
the impression that they do remove the event assignment if you modify the
code, not 100% sure though. I will open that project later today and will
let you konw.
 
[...]
Now I might be wrong but I'm using Infragistics controls lately and I
have
the impression that they do remove the event assignment if you modify the
code, not 100% sure though. I will open that project later today and will
let you konw.

I have, inexplicably, seen both behaviors in the VS designer. I have
definitely had trouble some times though where I delete the method, then
delete the event, but the assignment in the Designer.cs file remains. :(
I'm pretty sure I've also seen it allow me to delete the event handler
after the fact and not get messed up.

However, if the method is empty and you remove it from the event in the
designer, all is good. It's removed from the event, from the Designer.cs
code *and* the method itself is deleted from the source file for you.

Pete
 

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

Back
Top