dynamically displaying an image in a menu?
-
I want to display a check mark next to the text of a
ToolStripMenuItem
, when the user clicked on it. in the form editor I set theImageAlign
property toMiddleLeft
, that should display the image on the right side of the text or? But how do I achieve that the image gets displayed only whe the user clicks on the menu item? And whe he does, the image that was displayed for another menu option should be erased (so that the user see which of the options is selected and can see which one he selected)? I tried theImage
andImageList
properties, but I got an error: Invalid parameter Thanks. -
I want to display a check mark next to the text of a
ToolStripMenuItem
, when the user clicked on it. in the form editor I set theImageAlign
property toMiddleLeft
, that should display the image on the right side of the text or? But how do I achieve that the image gets displayed only whe the user clicks on the menu item? And whe he does, the image that was displayed for another menu option should be erased (so that the user see which of the options is selected and can see which one he selected)? I tried theImage
andImageList
properties, but I got an error: Invalid parameter Thanks.Well, I don't have my VS in front of me, so I'll do it out of my head. There are several possibility's. I think you should do something like this: In your code, make a function like this:
String[] imagePaths = {"mypic1.jpg", "mypic2.jpg", "mypic3.jpg"};
public void clearMenuItemImages()
{
mi1.Image = null;
mi2.Image = null;
mi3.Image = null;
}public void onMenuItem1Clicked(object sender, EventArgs e)
{
clearMenuItemImages();
((ToolStripMenuItem)sender).Image = imagePath[0];
}//etc.
You can make this faster and better, but this is a start.
-
I want to display a check mark next to the text of a
ToolStripMenuItem
, when the user clicked on it. in the form editor I set theImageAlign
property toMiddleLeft
, that should display the image on the right side of the text or? But how do I achieve that the image gets displayed only whe the user clicks on the menu item? And whe he does, the image that was displayed for another menu option should be erased (so that the user see which of the options is selected and can see which one he selected)? I tried theImage
andImageList
properties, but I got an error: Invalid parameter Thanks. -
Images ??? Alignment ??? What ???
ToolStripMenuItem
s have aChecked
Property. Set it totrue
to display a check mark next to the text, set it tofalse
to make the check mark go away.:Badger:
Thanks, that did the trick.