Windows Develop Bookmark and Share   
 index > Windows Forms General > Will I mess anything up if I delete this from the designer.cs file ?
 

Will I mess anything up if I delete this from the designer.cs file ?


I have gotten some errors with the designer.cs file when making alterations to my form. I had a label on a form. I decided to change the purpose of the label thus I wanted to change it's name to reflect it's new functionality. In the designer.cs file most of the names of the label changed except for one. I think I created this issue by getting rid of the click event for the old label which was created accidently Below I have named this one lblOldName.

Below is a piece from the designer.cs file for my project. As you can see the new name for the label is lblSticks. The last line has the old name in the EventHandler for lblOldName. I have been able to correct the error by giving this old name the new one.

I don't have a use for the click event for the label. Could I also have removed the line for the Click event handler (the entire last line) completely to correct this? Would this have caused other problems? I am guessing that removing any of the other lines would have caused problems as I still need these.

Would it have been sufficient to just remove the original event handler in the code behind file? Would this have automatically removed this bad line from the designer.cs file? Should I do this in the future.


// lblSticks
//
this.lblSticks.Anchor = System.Windows.Forms.AnchorStyles.None;
this.lblSticks.AutoSize = true;
this.lblSticks.Location = new System.Drawing.Point(35, 71);
this.lblSticks.Name = "lblSticks";
this.lblSticks.Size = new System.Drawing.Size(129, 13);
this.lblSticks.TabIndex = 7;
this.lblSticks.Text = "Are Sticks used to play it?";
this.lblSticks.Click += new System.EventHandler(this.lblOldName_Click); <---- this is what caused the error

-thanks for any help.
new to sql server  Sunday, October 12, 2008 7:55 PM
Editing the designer generated code in InitializeComponent() is a good way to blow your foot off. It is easy to get the code into a state where it throws an exception when the designer runs the form constructor, producing a WSOD, the White Screen Of Darn. Or crash Visual Studio to the desktop.

Change the name of a control by editing the Name property in the Properties window. Remove an event handler by clicking the lightning bolt icon and deleting the name of the event handler. But yes, deleting that line of code would do the same thing as deleting the event handler in the Properties window.
nobugz  Sunday, October 12, 2008 10:47 PM

Hello new to sql server,

For that specific line, probably not; I will often do that exact same thing. (Be sure to save before you try it though).

Hope this helps!

Thanks!

chukrum47

chukrum47  Monday, October 13, 2008 1:57 AM
Editing the designer generated code in InitializeComponent() is a good way to blow your foot off. It is easy to get the code into a state where it throws an exception when the designer runs the form constructor, producing a WSOD, the White Screen Of Darn. Or crash Visual Studio to the desktop.

Change the name of a control by editing the Name property in the Properties window. Remove an event handler by clicking the lightning bolt icon and deleting the name of the event handler. But yes, deleting that line of code would do the same thing as deleting the event handler in the Properties window.
nobugz  Sunday, October 12, 2008 10:47 PM

Hello new to sql server,

For that specific line, probably not; I will often do that exact same thing. (Be sure to save before you try it though).

Hope this helps!

Thanks!

chukrum47

chukrum47  Monday, October 13, 2008 1:57 AM

You can use google to search for other answers

Custom Search

More Threads

• Where to ask about detecting if an app (from window's HWND) has a modal dialog pending?
• arg - this exception makes no sense to me!
• vscrollbar and form
• Windows Form timer Tick memory leak
• Where to find MenuStrip programming elements(messages-functions-Notifications-Macros)
• FileSystemWatcher
• Multiple cell types in one column in DataGridView
• Changing DataMember shown in DataGridView
• Shortcut keys in Usercontrol not fired
• problem with System.Collections.Specialized.StringCollection