Changing icons in existing toolbar
I am having hard time trying to replace icons in an existing application that has a toolbar. The icons are placed under "img" directory. When I replace an old icon with a new one and build\start my project, I don't see the new icon. Can somebody let me know what am I doing wrong ?
Thanks a lot!
try
{
this.ExecutingAssembly = System.Reflection.Assembly.GetExecutingAssembly();
this.FormResources = new System.Resources.ResourceManager( "MyApp.MyAppForm", this.ExecutingAssembly );
Icon ic1 = (System.Drawing.Icon) this.FormResources.GetObject ("copy.ico");
Icon ic2 = (System.Drawing.Icon) this.FormResources.GetObject ("save.ico");
ImageList imglist = new ImageList();
imglist.Images.Add(ic1);
imglist.Images.Add(ic2);
this.toolBar.ImageList = imglist;
}
catch(Exception ex)
{
MessageBox.Show (ex.Message + ex.StackTrace);
}
for (int iToolButt = 0; iToolButt < toolbarText.Length; iToolButt ++)
{
ToolBarButton tButt = new ToolBarButton();
tButt.ImageIndex = iToolButt;
this.toolBar.Buttons.Add(tButt);
}
[1090 byte] By [
HLD77] at [2007-12-16]
I think this is happning since the images are not being replaced in the Resource file. The one way I know to solve it is to do "Show All Files" in the "solution explorer", expand the <formName>.cs file to reveal a <formName>.resx file. Delete this file (always keep a backup .. just in case).
Now double click on the Form to open it in Design View. This will force the IDE to create a new RESX file for you. Now try adding the new icons to the Toolbar. They should reflect in the Resx file.
Remember: Backup your project before trying this. You will have to replace all images after you perform this step.
Or you could also manually open the RESX file, delete the entries for the icons. And then add the Icons to the ImageList. so that the updated icons are stored.
Regards,
Saurabh Nandu
www.MasterCSharp.com
www.AksTech.com