473,378 Members | 1,383 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,378 software developers and data experts.

Hard coded Tool button image being remove by IDE automatically

Hi all,

Any criticism will be appreciated.

I have a project coded in VS.NET 2003, and I am moving to VS.NET 2005
and convert to Project to VS.NET 2005 Version. In the former project,
I have an object: POImageList which is type of
System.Windows.Forms.ImageList and holds 6 Images.

I add the following codes to InitializeComponent() part:

//
toolStripButton1.image = POImageList,Images[0];

Then I build and run the project, It works well and the result is
exactly what I want.

However, The Problem is:

When I return to the designer mode and build the project again, the
IDE remove the line: toolStripButton1.image = POImageList,Images[0];
When I run the project, Nothing appears on toolStripButton1. I tried
serveral times, but things are the same.

Does anyone else has this kind of problems?

Thanks again.
Nov 21 '07 #1
2 1976
Hi Kevin.Li

You shouldn't put any code in the InitializeComponent() method, as Visual
Studio can (and does) regenerate the method when you modify the form.
You should put your assignment in the constructor for your form, just after
the InitializeComponent() method is called. e.g.

public partial class UI : System.Windows.Forms.Form
{
public UI()
{
InitializeComponent();

toolStripButton1.image = POImageList,Images[0];
}

...
}

Making the assignment after the call to InitalizeComponent() ensures the
toolsStripButton1 object has been initialized.
And, Visual Studio will never overwrite the code in your own constructor.

Hope that helps

--
Ged Moretta
www.appsense.com

-----------------------------------------------------------------------
This signature isn't automatic. I have to type it manually every time.
"Kevin.Li" <li*********@gmail.comwrote in message
news:2c**********************************@w28g2000 hsf.googlegroups.com...
Hi all,

Any criticism will be appreciated.

I have a project coded in VS.NET 2003, and I am moving to VS.NET 2005
and convert to Project to VS.NET 2005 Version. In the former project,
I have an object: POImageList which is type of
System.Windows.Forms.ImageList and holds 6 Images.

I add the following codes to InitializeComponent() part:

//
toolStripButton1.image = POImageList,Images[0];

Then I build and run the project, It works well and the result is
exactly what I want.

However, The Problem is:

When I return to the designer mode and build the project again, the
IDE remove the line: toolStripButton1.image = POImageList,Images[0];
When I run the project, Nothing appears on toolStripButton1. I tried
serveral times, but things are the same.

Does anyone else has this kind of problems?

Thanks again.
Nov 21 '07 #2
On 11ÔÂ21ÈÕ, ÏÂÎç6ʱ54·Ö, <Gedwrote:
Hi Kevin.Li

You shouldn't put any code in the InitializeComponent() method, as Visual
Studio can (and does) regenerate the method when you modify the form.
You should put your assignment in the constructor for your form, just after
the InitializeComponent() method is called. e.g.

public partial class UI : System.Windows.Forms.Form
{
public UI()
{
InitializeComponent();

toolStripButton1.image = POImageList,Images[0];
}

...

}

Making the assignment after the call to InitalizeComponent() ensures the
toolsStripButton1 object has been initialized.
And, Visual Studio will never overwrite the code in your own constructor.

Hope that helps

--
Ged Morettawww.appsense.com

-----------------------------------------------------------------------
This signature isn't automatic. I have to type it manually every time.

"Kevin.Li" <lizhiwen...@gmail.comwrote in message

news:2c**********************************@w28g2000 hsf.googlegroups.com...
Hi all,
Any criticism will be appreciated.
I have a project coded in VS.NET 2003, and I am moving to VS.NET 2005
and convert to Project to VS.NET 2005 Version. In the former project,
I have an object: POImageList which is type of
System.Windows.Forms.ImageList and holds 6 Images.
I add the following codes to InitializeComponent() part:
//
toolStripButton1.image = POImageList,Images[0];
Then I build and run the project, It works well and the result is
exactly what I want.
However, The Problem is:
When I return to the designer mode and build the project again, the
IDE remove the line: toolStripButton1.image = POImageList,Images[0];
When I run the project, Nothing appears on toolStripButton1. I tried
serveral times, but things are the same.
Does anyone else has this kind of problems?
Thanks again.- Òþ²Ø±»ÒýÓÃÎÄ×Ö -

- ÏÔʾÒýÓõÄÎÄ×Ö -
Yeah!
Thanks a zillion.
Since I am a new hand in DotNet, I am confused with this problem for
the whole evening. OK, It's late in China now. I am going to bed. Your
answer will help me to enjoy a more comfortable sleep.

Thanks again.
Nov 21 '07 #3

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

Similar topics

1
by: Carl Hilton | last post by:
Trying to get Windows AD LDAP working to recognize who is accessing the page... I have successfully grabbed the user credentials and passed them off to LDAP, but that required me to pass off a hard...
7
by: dixie | last post by:
I have been running some code from a form's on open event to run regedit if a registry key does not exist in the registry. It has been working fine, but I have had the path to the registry fix...
1
by: Luis Esteban Valencia | last post by:
have a website that uses both http and https. I am able to change any hard coded http links to relative paths. No problem. But, I have several aspx and ascx pages that contain hard coded links...
8
by: Gabor | last post by:
Hi, I have an app. that uses an MSDE database. I hardcoded the login and password in the application, but it is very simple to see with an ILDASM.exe tool. Is it any procedure to obscure the...
10
by: Brett | last post by:
If I have many hard coded values such as file paths, file names, timeouts, etc, where is the best place to define them? Meaning, in the case something needs changing for example, rather than...
0
by: tjonsek | last post by:
I am working with directories in PHP for the first time. I have code that I've changed multiple times to try different things. I would think this is pretty standard fare so I'm not sure why I can't...
1
by: =?Utf-8?B?UkM=?= | last post by:
For some reason, my toolbar button for the Junk Reporting Tool has disappeared. I'm running OL2003 on XP. I've downloaded and installed the tool again, but the button still does not appear. There...
4
Lokean
by: Lokean | last post by:
The problem: Company was bought out and we are bringing everything into complience. Passwords are not secure and do not need to be.(required by software we are using) Old passwords *may or may...
1
by: nitzanO | last post by:
Hey, I have a very big project with thousands and thousands of code lines. Until now we have used hard-coded passwords and we wish to stop. The problem is how detect all the places in the code...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...

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.