G
Guest
Hi, everyone.
I'm trying to add an Icon to an ImageList control. I've set the icons to
Embedded Resource, and I'm following the steps listed in a post from Neville
Lang in November (thread about adding images to toolbars on an HP 47xx).
| i) Use .ICO files in the project (instead of BMP files)
| and set their Build Action to Embedded Resource
| ii) Changed my method call to:
|
| ImageList.Images.Add(new
| Icon(Assembly.GetExecutingAssembly().
| GetManifestResourceStream("MyProject.tb
| Image1.ico")))
|
| As stated in my earlier post, the above call(s) needs to be moved out of
| InitializeComponent() and placed after the InitializeComponent().
|
I'm trying to do something similar to this where I've moved the code to
create the Icon resource to a private function called GetIcon.
private Icon GetIcon(string name)
{
// Get the current assembly and open a stream to the icon file
Assembly execAssembly = Assembly.GetExecutingAssembly();
try
{
Stream fileStream = execAssembly.GetManifestResourceStream
(execAssembly.GetName().Name + "." + name + ".ico");
// Create and return the icon
Icon icon = new Icon(execAssembly.GetManifestResourceStream
(execAssembly.GetName().Name + "." + name + ".ico"));
}
catch(ArgumentException ex)
{
MessageBox.Show("Argument Exception: " + ex.Message +
"\n" + execAssembly.GetName().Name + "." + name + ".ico");
}
catch(Exception ex)
{
MessageBox.Show("System Exception: " + ex.Message);
}
return icon;
} // end Icon GetIcon(string icon)
I'm getting an Argument Exception when I try to run this code. In checking a
similar piece of code on the OpenNetCF forums, I found it doesn't like
assemblies with spaces in their names. However, I don't have a space in my
assembly name. Any ideas why this wouldn't work?
I've tried making the call to GetIcon in the ctor for formMain and in the
formMain_Load event. I get the same error each time. Here's the method call
I'm using:
this.imagelistMain.Images.Add(GetIcon("normal"));
My device is an Axim X3 with NetCF SP 3. I'm running into the problem on
both the emulator (also with SP3) and the device. Thanks for any help you can
provide. Please let me know if there's any other information you need from me.
Flynn
I'm trying to add an Icon to an ImageList control. I've set the icons to
Embedded Resource, and I'm following the steps listed in a post from Neville
Lang in November (thread about adding images to toolbars on an HP 47xx).
| i) Use .ICO files in the project (instead of BMP files)
| and set their Build Action to Embedded Resource
| ii) Changed my method call to:
|
| ImageList.Images.Add(new
| Icon(Assembly.GetExecutingAssembly().
| GetManifestResourceStream("MyProject.tb
| Image1.ico")))
|
| As stated in my earlier post, the above call(s) needs to be moved out of
| InitializeComponent() and placed after the InitializeComponent().
|
I'm trying to do something similar to this where I've moved the code to
create the Icon resource to a private function called GetIcon.
private Icon GetIcon(string name)
{
// Get the current assembly and open a stream to the icon file
Assembly execAssembly = Assembly.GetExecutingAssembly();
try
{
Stream fileStream = execAssembly.GetManifestResourceStream
(execAssembly.GetName().Name + "." + name + ".ico");
// Create and return the icon
Icon icon = new Icon(execAssembly.GetManifestResourceStream
(execAssembly.GetName().Name + "." + name + ".ico"));
}
catch(ArgumentException ex)
{
MessageBox.Show("Argument Exception: " + ex.Message +
"\n" + execAssembly.GetName().Name + "." + name + ".ico");
}
catch(Exception ex)
{
MessageBox.Show("System Exception: " + ex.Message);
}
return icon;
} // end Icon GetIcon(string icon)
I'm getting an Argument Exception when I try to run this code. In checking a
similar piece of code on the OpenNetCF forums, I found it doesn't like
assemblies with spaces in their names. However, I don't have a space in my
assembly name. Any ideas why this wouldn't work?
I've tried making the call to GetIcon in the ctor for formMain and in the
formMain_Load event. I get the same error each time. Here's the method call
I'm using:
this.imagelistMain.Images.Add(GetIcon("normal"));
My device is an Axim X3 with NetCF SP 3. I'm running into the problem on
both the emulator (also with SP3) and the device. Thanks for any help you can
provide. Please let me know if there's any other information you need from me.
Flynn