473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VS is adding code when compiling

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
InitializeComponent 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.Drawing.Icon)(resources.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 InitializeComponent method looks like this...

private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
// button1
this.button1.Location = new System.Drawing.Point(32, 56);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
// Form1
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}

In my solution it looks like this...

private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1));
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.AccessibleDescription =
resources.GetString("button1.AccessibleDescription ");
this.button1.AccessibleName =
resources.GetString("button1.AccessibleName");
this.button1.Anchor =
((System.Windows.Forms.AnchorStyles)(resources.Get Object("button1.Anchor")));
this.button1.BackgroundImage =
((System.Drawing.Image)(resources.GetObject("butto n1.BackgroundImage")));
this.button1.Dock =
((System.Windows.Forms.DockStyle)(resources.GetObj ect("button1.Dock")));
this.button1.Enabled =
((bool)(resources.GetObject("button1.Enabled")));
this.button1.FlatStyle =
((System.Windows.Forms.FlatStyle)(resources.GetObj ect("button1.FlatStyle")));
this.button1.Font =
((System.Drawing.Font)(resources.GetObject("button 1.Font")));
this.button1.Image =
((System.Drawing.Image)(resources.GetObject("butto n1.Image")));
this.button1.ImageAlign =
((System.Drawing.ContentAlignment)(resources.GetOb ject("button1.ImageAlign")));
this.button1.ImageIndex =
((int)(resources.GetObject("button1.ImageIndex"))) ;
this.button1.ImeMode =
((System.Windows.Forms.ImeMode)(resources.GetObjec t("button1.ImeMode")));
this.button1.Location =
((System.Drawing.Point)(resources.GetObject("butto n1.Location")));
this.button1.Name = "button1";
this.button1.RightToLeft =
((System.Windows.Forms.RightToLeft)(resources.GetO bject("button1.RightToLeft")));
this.button1.Size =
((System.Drawing.Size)(resources.GetObject("button 1.Size")));
this.button1.TabIndex =
((int)(resources.GetObject("button1.TabIndex")));
this.button1.Text = resources.GetString("button1.Text");
this.button1.TextAlign =
((System.Drawing.ContentAlignment)(resources.GetOb ject("button1.TextAlign")));
this.button1.Visible =
((bool)(resources.GetObject("button1.Visible")));
// Form1
this.AccessibleDescription =
resources.GetString("$this.AccessibleDescription") ;
this.AccessibleName = resources.GetString("$this.AccessibleName");
this.AutoScaleBaseSize =
((System.Drawing.Size)(resources.GetObject("$this. AutoScaleBaseSize")));
this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
this.AutoScrollMargin =
((System.Drawing.Size)(resources.GetObject("$this. AutoScrollMargin")));
this.AutoScrollMinSize =
((System.Drawing.Size)(resources.GetObject("$this. AutoScrollMinSize")));
this.BackgroundImage =
((System.Drawing.Image)(resources.GetObject("$this .BackgroundImage")));
this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this. ClientSize")));
this.Controls.Add(this.button1);
this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
this.Font = ((System.Drawing.Font)(resources.GetObject("$this. Font")));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this. Icon")));
this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObjec t("$this.ImeMode")));
this.Location = ((System.Drawing.Point)(resources.GetObject("$this .Location")));
this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this. MaximumSize")));
this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this. MinimumSize")));
this.Name = "Form1";
this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetO bject("$this.RightToLeft")));
this.StartPosition =
((System.Windows.Forms.FormStartPosition)(resource s.GetObject("$this.StartPosition")));
this.Text = resources.GetString("$this.Text");
this.ResumeLayout(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
Jul 21 '05 #1
1 1078
On 1 Apr 2004 05:15:07 -0800, Jonas L <jo***@bootman.se> wrote:
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


Check the Localizable property on the form. You probably have set it to
true, which makes all the properties be put in resources which allow you
to localize the form.

--
Lasse Vågsæther Karlsen
http://www.vkarlsen.no/
PGP KeyID: 0x0270466B
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Geoff Biggs | last post by:
Evening all, I'm trying to add a new built-in number data type to Python with its own syntax, so I'm working directly with the interpreter rather than creating my own extension module (side...
1
by: Jonas L | last post by:
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....
1
by: Jax | last post by:
I am looking to populate web page with controls as a result of a database query. eg (pseudocode) <% foreach(Garment g in GetStuffFromDB()) { //add controls Response.Write("<asp:Button id =...
4
by: Aaron Queenan | last post by:
When I build a C++ library to .NET using the managed C++ compiler, I get the following error message: Linking... LINK : error LNK2020: unresolved token (0A000005) _CrtDbgReport LINK : error...
2
by: Neil Guyette | last post by:
Hello, All, It would be greatly appreciated if someone could throw me the bone on this question! I'm working on a project in Visual C++ .NET. I'm trying to generate a list of SQL servers that...
12
by: Wardeaux | last post by:
All, Wanting to find a way to create web pages to add to my website without having to recompile the codebehind everytime I want to add a new one... Here's the deal: I have a web app that takes...
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
18
by: Praveen Ramesh | last post by:
Hi, Is there any way to add the @Assembly reference to the aspx files programmatically from inside a custom control (when it gets dropped on to the page from the toolbox)? I have a custom...
3
by: rcoco | last post by:
Hi, I'm trying to Insert a new Row on a dagrid. When I did a google search, I got an example on this address: http://www.codeproject.com/ASPNET_DataGrid.asp. I've done mycode as follows: ...
12
by: Jeff Gaines | last post by:
I am a hobbyist programmer, using C# and VS2008 and writing desktop apps. I am trying hard to take a modular approach to avoid re-inventing the wheel but I'm finding it a bit frustrating. For...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.