I have created a derived version of a normal form, e.g. called MyForm
(public class MyForm : System.Windows. Forms.Form). The form is simply
specifing a standard icon that we use within the company. This fairly
straight forward and not a problem. We have planed to use this form as
the base form to all other forms in our application.
The problem is the following...
When adding a button (or any other control) to the myForm the
designer/IDE(?) adds some code automatically in the
InitializeCompo nent method. This is also normal but in my case it add
more code than normal. Below is two pieces of code that shows my
problem. Executing the solution/project causes the form icon to change
from the company specific icon to the standard (blue/yellow/red)
icon!? If I remove the following piece of code the problem disappears,
but returns if I add a new control to the form.
this.Icon = ((System.Drawin g.Icon)(resourc es.GetObject("$ this.Icon")));
This seems to a problem that is local to the solution and/or project.
I have tried to replicate the problem in other solutions without
success :( If I use a normal form (derived from
System.Windows. Forms.Form) the problem does not emerge!?
What have I done to deserve this?? How do I solve this?
Normally the InitializeCompo nent method looks like this...
private void InitializeCompo nent()
{
this.button1 = new System.Windows. Forms.Button();
this.SuspendLay out();
// button1
this.button1.Lo cation = new System.Drawing. Point(32, 56);
this.button1.Na me = "button1";
this.button1.Ta bIndex = 0;
this.button1.Te xt = "button1";
// Form1
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(292, 273);
this.Controls.A dd(this.button1 );
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);
}
In my solution it looks like this...
private void InitializeCompo nent()
{
System.Resource s.ResourceManag er resources = new
System.Resource s.ResourceManag er(typeof(Form1 ));
this.button1 = new System.Windows. Forms.Button();
this.SuspendLay out();
//
// button1
//
this.button1.Ac cessibleDescrip tion =
resources.GetSt ring("button1.A ccessibleDescri ption");
this.button1.Ac cessibleName =
resources.GetSt ring("button1.A ccessibleName") ;
this.button1.An chor =
((System.Window s.Forms.AnchorS tyles)(resource s.GetObject("bu tton1.Anchor")) );
this.button1.Ba ckgroundImage =
((System.Drawin g.Image)(resour ces.GetObject(" button1.Backgro undImage")));
this.button1.Do ck =
((System.Window s.Forms.DockSty le)(resources.G etObject("butto n1.Dock")));
this.button1.En abled =
((bool)(resourc es.GetObject("b utton1.Enabled" )));
this.button1.Fl atStyle =
((System.Window s.Forms.FlatSty le)(resources.G etObject("butto n1.FlatStyle")) );
this.button1.Fo nt =
((System.Drawin g.Font)(resourc es.GetObject("b utton1.Font"))) ;
this.button1.Im age =
((System.Drawin g.Image)(resour ces.GetObject(" button1.Image") ));
this.button1.Im ageAlign =
((System.Drawin g.ContentAlignm ent)(resources. GetObject("butt on1.ImageAlign" )));
this.button1.Im ageIndex =
((int)(resource s.GetObject("bu tton1.ImageInde x")));
this.button1.Im eMode =
((System.Window s.Forms.ImeMode )(resources.Get Object("button1 .ImeMode")));
this.button1.Lo cation =
((System.Drawin g.Point)(resour ces.GetObject(" button1.Locatio n")));
this.button1.Na me = "button1";
this.button1.Ri ghtToLeft =
((System.Window s.Forms.RightTo Left)(resources .GetObject("but ton1.RightToLef t")));
this.button1.Si ze =
((System.Drawin g.Size)(resourc es.GetObject("b utton1.Size"))) ;
this.button1.Ta bIndex =
((int)(resource s.GetObject("bu tton1.TabIndex" )));
this.button1.Te xt = resources.GetSt ring("button1.T ext");
this.button1.Te xtAlign =
((System.Drawin g.ContentAlignm ent)(resources. GetObject("butt on1.TextAlign") ));
this.button1.Vi sible =
((bool)(resourc es.GetObject("b utton1.Visible" )));
// Form1
this.Accessible Description =
resources.GetSt ring("$this.Acc essibleDescript ion");
this.Accessible Name = resources.GetSt ring("$this.Acc essibleName");
this.AutoScaleB aseSize =
((System.Drawin g.Size)(resourc es.GetObject("$ this.AutoScaleB aseSize")));
this.AutoScroll = ((bool)(resourc es.GetObject("$ this.AutoScroll ")));
this.AutoScroll Margin =
((System.Drawin g.Size)(resourc es.GetObject("$ this.AutoScroll Margin")));
this.AutoScroll MinSize =
((System.Drawin g.Size)(resourc es.GetObject("$ this.AutoScroll MinSize")));
this.Background Image =
((System.Drawin g.Image)(resour ces.GetObject(" $this.Backgroun dImage")));
this.ClientSize = ((System.Drawin g.Size)(resourc es.GetObject("$ this.ClientSize ")));
this.Controls.A dd(this.button1 );
this.Enabled = ((bool)(resourc es.GetObject("$ this.Enabled")) );
this.Font = ((System.Drawin g.Font)(resourc es.GetObject("$ this.Font")));
this.Icon = ((System.Drawin g.Icon)(resourc es.GetObject("$ this.Icon")));
this.ImeMode = ((System.Window s.Forms.ImeMode )(resources.Get Object("$this.I meMode")));
this.Location = ((System.Drawin g.Point)(resour ces.GetObject(" $this.Location" )));
this.MaximumSiz e = ((System.Drawin g.Size)(resourc es.GetObject("$ this.MaximumSiz e")));
this.MinimumSiz e = ((System.Drawin g.Size)(resourc es.GetObject("$ this.MinimumSiz e")));
this.Name = "Form1";
this.RightToLef t = ((System.Window s.Forms.RightTo Left)(resources .GetObject("$th is.RightToLeft" )));
this.StartPosit ion =
((System.Window s.Forms.FormSta rtPosition)(res ources.GetObjec t("$this.StartP osition")));
this.Text = resources.GetSt ring("$this.Tex t");
this.ResumeLayo ut(false);
}
The version of Microsoft Development Environment 2003 is 7.1.3008
The version of Microsoft .NET Framework 1.1 is 1.1.4322
//Jonas
(public class MyForm : System.Windows. Forms.Form). The form is simply
specifing a standard icon that we use within the company. This fairly
straight forward and not a problem. We have planed to use this form as
the base form to all other forms in our application.
The problem is the following...
When adding a button (or any other control) to the myForm the
designer/IDE(?) adds some code automatically in the
InitializeCompo nent method. This is also normal but in my case it add
more code than normal. Below is two pieces of code that shows my
problem. Executing the solution/project causes the form icon to change
from the company specific icon to the standard (blue/yellow/red)
icon!? If I remove the following piece of code the problem disappears,
but returns if I add a new control to the form.
this.Icon = ((System.Drawin g.Icon)(resourc es.GetObject("$ this.Icon")));
This seems to a problem that is local to the solution and/or project.
I have tried to replicate the problem in other solutions without
success :( If I use a normal form (derived from
System.Windows. Forms.Form) the problem does not emerge!?
What have I done to deserve this?? How do I solve this?
Normally the InitializeCompo nent method looks like this...
private void InitializeCompo nent()
{
this.button1 = new System.Windows. Forms.Button();
this.SuspendLay out();
// button1
this.button1.Lo cation = new System.Drawing. Point(32, 56);
this.button1.Na me = "button1";
this.button1.Ta bIndex = 0;
this.button1.Te xt = "button1";
// Form1
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(292, 273);
this.Controls.A dd(this.button1 );
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);
}
In my solution it looks like this...
private void InitializeCompo nent()
{
System.Resource s.ResourceManag er resources = new
System.Resource s.ResourceManag er(typeof(Form1 ));
this.button1 = new System.Windows. Forms.Button();
this.SuspendLay out();
//
// button1
//
this.button1.Ac cessibleDescrip tion =
resources.GetSt ring("button1.A ccessibleDescri ption");
this.button1.Ac cessibleName =
resources.GetSt ring("button1.A ccessibleName") ;
this.button1.An chor =
((System.Window s.Forms.AnchorS tyles)(resource s.GetObject("bu tton1.Anchor")) );
this.button1.Ba ckgroundImage =
((System.Drawin g.Image)(resour ces.GetObject(" button1.Backgro undImage")));
this.button1.Do ck =
((System.Window s.Forms.DockSty le)(resources.G etObject("butto n1.Dock")));
this.button1.En abled =
((bool)(resourc es.GetObject("b utton1.Enabled" )));
this.button1.Fl atStyle =
((System.Window s.Forms.FlatSty le)(resources.G etObject("butto n1.FlatStyle")) );
this.button1.Fo nt =
((System.Drawin g.Font)(resourc es.GetObject("b utton1.Font"))) ;
this.button1.Im age =
((System.Drawin g.Image)(resour ces.GetObject(" button1.Image") ));
this.button1.Im ageAlign =
((System.Drawin g.ContentAlignm ent)(resources. GetObject("butt on1.ImageAlign" )));
this.button1.Im ageIndex =
((int)(resource s.GetObject("bu tton1.ImageInde x")));
this.button1.Im eMode =
((System.Window s.Forms.ImeMode )(resources.Get Object("button1 .ImeMode")));
this.button1.Lo cation =
((System.Drawin g.Point)(resour ces.GetObject(" button1.Locatio n")));
this.button1.Na me = "button1";
this.button1.Ri ghtToLeft =
((System.Window s.Forms.RightTo Left)(resources .GetObject("but ton1.RightToLef t")));
this.button1.Si ze =
((System.Drawin g.Size)(resourc es.GetObject("b utton1.Size"))) ;
this.button1.Ta bIndex =
((int)(resource s.GetObject("bu tton1.TabIndex" )));
this.button1.Te xt = resources.GetSt ring("button1.T ext");
this.button1.Te xtAlign =
((System.Drawin g.ContentAlignm ent)(resources. GetObject("butt on1.TextAlign") ));
this.button1.Vi sible =
((bool)(resourc es.GetObject("b utton1.Visible" )));
// Form1
this.Accessible Description =
resources.GetSt ring("$this.Acc essibleDescript ion");
this.Accessible Name = resources.GetSt ring("$this.Acc essibleName");
this.AutoScaleB aseSize =
((System.Drawin g.Size)(resourc es.GetObject("$ this.AutoScaleB aseSize")));
this.AutoScroll = ((bool)(resourc es.GetObject("$ this.AutoScroll ")));
this.AutoScroll Margin =
((System.Drawin g.Size)(resourc es.GetObject("$ this.AutoScroll Margin")));
this.AutoScroll MinSize =
((System.Drawin g.Size)(resourc es.GetObject("$ this.AutoScroll MinSize")));
this.Background Image =
((System.Drawin g.Image)(resour ces.GetObject(" $this.Backgroun dImage")));
this.ClientSize = ((System.Drawin g.Size)(resourc es.GetObject("$ this.ClientSize ")));
this.Controls.A dd(this.button1 );
this.Enabled = ((bool)(resourc es.GetObject("$ this.Enabled")) );
this.Font = ((System.Drawin g.Font)(resourc es.GetObject("$ this.Font")));
this.Icon = ((System.Drawin g.Icon)(resourc es.GetObject("$ this.Icon")));
this.ImeMode = ((System.Window s.Forms.ImeMode )(resources.Get Object("$this.I meMode")));
this.Location = ((System.Drawin g.Point)(resour ces.GetObject(" $this.Location" )));
this.MaximumSiz e = ((System.Drawin g.Size)(resourc es.GetObject("$ this.MaximumSiz e")));
this.MinimumSiz e = ((System.Drawin g.Size)(resourc es.GetObject("$ this.MinimumSiz e")));
this.Name = "Form1";
this.RightToLef t = ((System.Window s.Forms.RightTo Left)(resources .GetObject("$th is.RightToLeft" )));
this.StartPosit ion =
((System.Window s.Forms.FormSta rtPosition)(res ources.GetObjec t("$this.StartP osition")));
this.Text = resources.GetSt ring("$this.Tex t");
this.ResumeLayo ut(false);
}
The version of Microsoft Development Environment 2003 is 7.1.3008
The version of Microsoft .NET Framework 1.1 is 1.1.4322
//Jonas
Comment