c# - When changing name of button breaks code -


okay think should explain in more detail, have code:

namespace hospitalmonitor {     partial class centralstation     {         /// <summary>         /// required designer variable.         /// </summary>         private system.componentmodel.icontainer components = null;          /// <summary>         /// clean resources being used.         /// </summary>         /// <param name="disposing">true if managed resources should disposed; otherwise, false.</param>         protected override void dispose(bool disposing)         {             if (disposing && (components != null))             {                 components.dispose();             }             base.dispose(disposing);         }          #region windows form designer generated code          /// <summary>         /// required method designer support - not modify         /// contents of method code editor.         /// </summary>         private void initializecomponent()         {             system.componentmodel.componentresourcemanager resources = new system.componentmodel.componentresourcemanager(typeof(centralstation));             centralmodule8 = new hospitalmonitor.centralmodule();             centralmodule7 = new hospitalmonitor.centralmodule();             centralmodule6 = new hospitalmonitor.centralmodule();             centralmodule5 = new hospitalmonitor.centralmodule();             centralmodule4 = new hospitalmonitor.centralmodule();             centralmodule3 = new hospitalmonitor.centralmodule();             centralmodule2 = new hospitalmonitor.centralmodule();             centralmodule1 = new hospitalmonitor.centralmodule();             this.regderegstaff = new system.windows.forms.button();             this.button2 = new system.windows.forms.button();             this.button3 = new system.windows.forms.button();             this.button4 = new system.windows.forms.button();             this.suspendlayout();             //              // centralmodule8             //              centralmodule8.borderstyle = system.windows.forms.borderstyle.fixed3d;             centralmodule8.location = new system.drawing.point(705, 348);             centralmodule8.name = "centralmodule8";             centralmodule8.size = new system.drawing.size(225, 248);             centralmodule8.tabindex = 7;             //              // centralmodule7             //              centralmodule7.borderstyle = system.windows.forms.borderstyle.fixed3d;             centralmodule7.location = new system.drawing.point(474, 348);             centralmodule7.name = "centralmodule7";             centralmodule7.size = new system.drawing.size(225, 248);             centralmodule7.tabindex = 6;             //              // centralmodule6             //              centralmodule6.borderstyle = system.windows.forms.borderstyle.fixed3d;             centralmodule6.location = new system.drawing.point(243, 348);             centralmodule6.name = "centralmodule6";             centralmodule6.size = new system.drawing.size(225, 248);             centralmodule6.tabindex = 5;             //              // centralmodule5             //              centralmodule5.borderstyle = system.windows.forms.borderstyle.fixed3d;             centralmodule5.location = new system.drawing.point(12, 348);             centralmodule5.name = "centralmodule5";             centralmodule5.size = new system.drawing.size(225, 248);             centralmodule5.tabindex = 4;             //              // centralmodule4             //              centralmodule4.borderstyle = system.windows.forms.borderstyle.fixed3d;             centralmodule4.location = new system.drawing.point(705, 12);             centralmodule4.name = "centralmodule4";             centralmodule4.size = new system.drawing.size(225, 248);             centralmodule4.tabindex = 3;             //              // centralmodule3             //              centralmodule3.borderstyle = system.windows.forms.borderstyle.fixed3d;             centralmodule3.location = new system.drawing.point(474, 12);             centralmodule3.name = "centralmodule3";             centralmodule3.size = new system.drawing.size(225, 248);             centralmodule3.tabindex = 2;             //              // centralmodule2             //              centralmodule2.borderstyle = system.windows.forms.borderstyle.fixed3d;             centralmodule2.location = new system.drawing.point(243, 12);             centralmodule2.name = "centralmodule2";             centralmodule2.size = new system.drawing.size(225, 248);             centralmodule2.tabindex = 1;             //              // centralmodule1             //              centralmodule1.borderstyle = system.windows.forms.borderstyle.fixed3d;             centralmodule1.location = new system.drawing.point(12, 12);             centralmodule1.name = "centralmodule1";             centralmodule1.size = new system.drawing.size(225, 248);             centralmodule1.tabindex = 0;             //              // regderegstaff             //              this.regderegstaff.location = new system.drawing.point(12, 292);             this.regderegstaff.name = "regderegstaff";             this.regderegstaff.size = new system.drawing.size(75, 23);             this.regderegstaff.tabindex = 8;             this.regderegstaff.text = "button1";             this.regderegstaff.usevisualstylebackcolor = true;             //              // button2             //              this.button2.location = new system.drawing.point(243, 292);             this.button2.name = "button2";             this.button2.size = new system.drawing.size(75, 23);             this.button2.tabindex = 9;             this.button2.text = "button2";             this.button2.usevisualstylebackcolor = true;             //              // button3             //              this.button3.location = new system.drawing.point(474, 292);             this.button3.name = "button3";             this.button3.size = new system.drawing.size(75, 23);             this.button3.tabindex = 10;             this.button3.text = "button3";             this.button3.usevisualstylebackcolor = true;             //              // button4             //              this.button4.location = new system.drawing.point(705, 292);             this.button4.name = "button4";             this.button4.size = new system.drawing.size(75, 23);             this.button4.tabindex = 11;             this.button4.text = "button4";             this.button4.usevisualstylebackcolor = true;             //              // centralstation             //              this.autoscaledimensions = new system.drawing.sizef(6f, 13f);             this.autoscalemode = system.windows.forms.autoscalemode.font;             this.clientsize = new system.drawing.size(948, 608);             this.controls.add(this.button4);             this.controls.add(this.button3);             this.controls.add(this.button2);             this.controls.add(this.regderegstaff);             this.controls.add(centralmodule8);             this.controls.add(centralmodule7);             this.controls.add(centralmodule6);             this.controls.add(centralmodule5);             this.controls.add(centralmodule4);             this.controls.add(centralmodule3);             this.controls.add(centralmodule2);             this.controls.add(centralmodule1);             this.icon = ((system.drawing.icon)(resources.getobject("$this.icon")));             this.name = "centralstation";             this.text = "central station overview";             this.resumelayout(false);          }          #endregion         private system.windows.forms.button regderegstaff;         private system.windows.forms.button button2;         private system.windows.forms.button button3;         private system.windows.forms.button button4;         private static centralmodule centralmodule1;         private static centralmodule centralmodule2;         private static centralmodule centralmodule3;         private static centralmodule centralmodule4;         private static centralmodule centralmodule5;         private static centralmodule centralmodule6;         private static centralmodule centralmodule7;         private static centralmodule centralmodule8;     } } 

this code works, when change name of button changes , breaks , have go through everytime delete this. errors are. question is, there way stop doing automatically? getting fed of having go , remove them.

namespace hospitalmonitor {     partial class centralstation     {         /// <summary>         /// required designer variable.         /// </summary>         private system.componentmodel.icontainer components = null;          /// <summary>         /// clean resources being used.         /// </summary>         /// <param name="disposing">true if managed resources should disposed; otherwise, false.</param>         protected override void dispose(bool disposing)         {             if (disposing && (components != null))             {                 components.dispose();             }             base.dispose(disposing);         }          #region windows form designer generated code          /// <summary>         /// required method designer support - not modify         /// contents of method code editor.         /// </summary>         private void initializecomponent()         {             system.componentmodel.componentresourcemanager resources = new system.componentmodel.componentresourcemanager(typeof(centralstation));             this.centralmodule8 = new hospitalmonitor.centralmodule();             this.centralmodule7 = new hospitalmonitor.centralmodule();             this.centralmodule6 = new hospitalmonitor.centralmodule();             this.centralmodule5 = new hospitalmonitor.centralmodule();             this.centralmodule4 = new hospitalmonitor.centralmodule();             this.centralmodule3 = new hospitalmonitor.centralmodule();             this.centralmodule2 = new hospitalmonitor.centralmodule();             this.centralmodule1 = new hospitalmonitor.centralmodule();             this.regderegstaff = new system.windows.forms.button();             this.button2 = new system.windows.forms.button();             this.button3 = new system.windows.forms.button();             this.button4 = new system.windows.forms.button();             this.suspendlayout();             //              // centralmodule8             //              this.centralmodule8.borderstyle = system.windows.forms.borderstyle.fixed3d;             this.centralmodule8.location = new system.drawing.point(705, 348);             this.centralmodule8.name = "centralmodule8";             this.centralmodule8.size = new system.drawing.size(225, 248);             this.centralmodule8.tabindex = 7;             //              // centralmodule7             //              this.centralmodule7.borderstyle = system.windows.forms.borderstyle.fixed3d;             this.centralmodule7.location = new system.drawing.point(474, 348);             this.centralmodule7.name = "centralmodule7";             this.centralmodule7.size = new system.drawing.size(225, 248);             this.centralmodule7.tabindex = 6;             //              // centralmodule6             //              this.centralmodule6.borderstyle = system.windows.forms.borderstyle.fixed3d;             this.centralmodule6.location = new system.drawing.point(243, 348);             this.centralmodule6.name = "centralmodule6";             this.centralmodule6.size = new system.drawing.size(225, 248);             this.centralmodule6.tabindex = 5;             //              // centralmodule5             //              this.centralmodule5.borderstyle = system.windows.forms.borderstyle.fixed3d;             this.centralmodule5.location = new system.drawing.point(12, 348);             this.centralmodule5.name = "centralmodule5";             this.centralmodule5.size = new system.drawing.size(225, 248);             this.centralmodule5.tabindex = 4;             //              // centralmodule4             //              this.centralmodule4.borderstyle = system.windows.forms.borderstyle.fixed3d;             this.centralmodule4.location = new system.drawing.point(705, 12);             this.centralmodule4.name = "centralmodule4";             this.centralmodule4.size = new system.drawing.size(225, 248);             this.centralmodule4.tabindex = 3;             //              // centralmodule3             //              this.centralmodule3.borderstyle = system.windows.forms.borderstyle.fixed3d;             this.centralmodule3.location = new system.drawing.point(474, 12);             this.centralmodule3.name = "centralmodule3";             this.centralmodule3.size = new system.drawing.size(225, 248);             this.centralmodule3.tabindex = 2;             //              // centralmodule2             //              this.centralmodule2.borderstyle = system.windows.forms.borderstyle.fixed3d;             this.centralmodule2.location = new system.drawing.point(243, 12);             this.centralmodule2.name = "centralmodule2";             this.centralmodule2.size = new system.drawing.size(225, 248);             this.centralmodule2.tabindex = 1;             //              // centralmodule1             //              this.centralmodule1.borderstyle = system.windows.forms.borderstyle.fixed3d;             this.centralmodule1.location = new system.drawing.point(12, 12);             this.centralmodule1.name = "centralmodule1";             this.centralmodule1.size = new system.drawing.size(225, 248);             this.centralmodule1.tabindex = 0;             //              // regderegstaff             //              this.regderegstaff.location = new system.drawing.point(12, 292);             this.regderegstaff.name = "regderegstaff";             this.regderegstaff.size = new system.drawing.size(154, 23);             this.regderegstaff.tabindex = 8;             this.regderegstaff.text = "register/deregister staff";             this.regderegstaff.usevisualstylebackcolor = true;             //              // button2             //              this.button2.location = new system.drawing.point(243, 292);             this.button2.name = "button2";             this.button2.size = new system.drawing.size(75, 23);             this.button2.tabindex = 9;             this.button2.text = "button2";             this.button2.usevisualstylebackcolor = true;             //              // button3             //              this.button3.location = new system.drawing.point(474, 292);             this.button3.name = "button3";             this.button3.size = new system.drawing.size(75, 23);             this.button3.tabindex = 10;             this.button3.text = "button3";             this.button3.usevisualstylebackcolor = true;             //              // button4             //              this.button4.location = new system.drawing.point(705, 292);             this.button4.name = "button4";             this.button4.size = new system.drawing.size(75, 23);             this.button4.tabindex = 11;             this.button4.text = "button4";             this.button4.usevisualstylebackcolor = true;             //              // centralstation             //              this.autoscaledimensions = new system.drawing.sizef(6f, 13f);             this.autoscalemode = system.windows.forms.autoscalemode.font;             this.clientsize = new system.drawing.size(948, 608);             this.controls.add(this.button4);             this.controls.add(this.button3);             this.controls.add(this.button2);             this.controls.add(this.regderegstaff);             this.controls.add(this.centralmodule8);             this.controls.add(this.centralmodule7);             this.controls.add(this.centralmodule6);             this.controls.add(this.centralmodule5);             this.controls.add(this.centralmodule4);             this.controls.add(this.centralmodule3);             this.controls.add(this.centralmodule2);             this.controls.add(this.centralmodule1);             this.icon = ((system.drawing.icon)(resources.getobject("$this.icon")));             this.name = "centralstation";             this.text = "central station overview";             this.resumelayout(false);          }          #endregion         private system.windows.forms.button regderegstaff;         private system.windows.forms.button button2;         private system.windows.forms.button button3;         private system.windows.forms.button button4;         private centralmodule centralmodule1;         private centralmodule centralmodule2;         private centralmodule centralmodule3;         private centralmodule centralmodule4;         private centralmodule centralmodule5;         private centralmodule centralmodule6;         private centralmodule centralmodule7;         private centralmodule centralmodule8;     } } 

simply remove static keyword within designer file @ end. control created through designer, should not have it.

private static centralmodule centralmodule1; private static centralmodule centralmodule2; private static centralmodule centralmodule3; private static centralmodule centralmodule4; private static centralmodule centralmodule5; private static centralmodule centralmodule6; private static centralmodule centralmodule7; private static centralmodule centralmodule8; 

also in general bad idea have static controls. if try show them on 2 places fail, doesn't make sense have them static.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -