473,609 Members | 1,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 InitializeCompo nent() part:

//
toolStripButton 1.image = POImageList,Ima ges[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: toolStripButton 1.image = POImageList,Ima ges[0];
When I run the project, Nothing appears on toolStripButton 1. I tried
serveral times, but things are the same.

Does anyone else has this kind of problems?

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

You shouldn't put any code in the InitializeCompo nent() 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 InitializeCompo nent() method is called. e.g.

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

toolStripButton 1.image = POImageList,Ima ges[0];
}

...
}

Making the assignment after the call to InitalizeCompon ent() ensures the
toolsStripButto n1 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*********@gm ail.comwrote in message
news:2c******** *************** ***********@w28 g2000hsf.google groups.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 InitializeCompo nent() part:

//
toolStripButton 1.image = POImageList,Ima ges[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: toolStripButton 1.image = POImageList,Ima ges[0];
When I run the project, Nothing appears on toolStripButton 1. 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 InitializeCompo nent() 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 InitializeCompo nent() method is called. e.g.

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

toolStripButton 1.image = POImageList,Ima ges[0];
}

...

}

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

Hope that helps

--
Ged Morettawww.apps ense.com

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

"Kevin.Li" <lizhiwen...@gm ail.comwrote in message

news:2c******** *************** ***********@w28 g2000hsf.google groups.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 InitializeCompo nent() part:
//
toolStripButton 1.image = POImageList,Ima ges[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: toolStripButton 1.image = POImageList,Ima ges[0];
When I run the project, Nothing appears on toolStripButton 1. 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
2309
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 coded Userid and password. Since this server is on our corporate network. Is there a way to either: 1) Grab the userid/password of the client and use them to access the windows LDAP server withouth having to give out my own? or 2) Protect...
7
2207
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 file hard coded into the VBA like this. RunReg = Shell("regedit.exe /s F:\MyFolder\SQLfix.reg", 0) Now I wish to make this more generic and allow it to run from any path. I have tried to use CurrentProjectPath like this.
1
1851
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 that are https. I have to get rid of those, asap. I know HTML and beginning+ C#. I have heard that you do something in the web config? I guess that would be ideal. I only have about 10 pages that need the https links to be relative.
8
3637
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 hard coded connection string, or how can I connect to the database with an encrypted password? Thanks in advance
10
2828
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 running down all the subs or functions that may contain these values, I'd like one place to change them and have that changed reflected in the subs or functions that use those values. I'd like to avoid globals; keeping the values private to only those...
0
1606
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 seem to get it right. What I would like to see happen: The code opens the directory and loops through the files, opening them and processing them.
1
1171
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 is also no mention of this Tool in Add/Remove Programs. How can I get it back? Also, just wondering, when I try to post this, I have to select a Discussion Group, but the list of groups is monstrous and NOT ALPHABETIZED!! How does anyone find...
4
2317
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 not have been hard coded* in SQL SERVER database to validate (each account was setup with the same generic password). Need to check each proc or function for presense of hard-coded password. We have hundreds of functions that may or may not...
1
2704
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 where we used hard-coded passwords - Do you know a way of doing it automatically? If there is a free or not-free program that you know that can help it will be good. Thanks alot!
0
8555
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8232
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8408
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7024
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6064
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4032
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4098
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1686
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.