Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Image margin from ToolStripMenuItem

Status
Not open for further replies.

snyperx3

Programmer
May 31, 2005
467
US
I'm just beginning to program in VB2005. I'm experimenting with NotifyIcon / ContextMenu. I am able to remove the Image margin from the context menu (ShowImageMargin = false), but I cant find any way to remove the margin from any items within the context menu.

I have attached an image to better show my problem.

Thanks

-Pete
 
This link should give you what you need:

How to: Configure MenuStrip Check Margins and Image Margins

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Thanks for your suggestion.

I tried going through that yesterday but came across a problem. I ran the program using this on Form_Load

Code:
CType(tsmiAutumn.DropDown, ContextMenuStrip).ShowImageMargin = False

I received the error:

"Unable to cast object of type 'System.Windows.Forms.ToolStripDropDownMenu' to type 'System.Windows.Forms.ContextMenuStrip'"

-Pete
 
You need to post the code you ended up using. If you used only that line of code then that isn't enough.

-I hate Microsoft!
-Forever and always forward.
 
I created the toolstripmenuitem in design. It's not being created at run time.

Is that the cause of the problem?

If I create the menu at run time how do I associate code with the Click event?

-Pete
 
I created the toolstripmenuitem in design. It's not being created at run time.

Is that the cause of the problem?
It is only a problem if you coded it wrong. We would really need to see the code to help you fix it.

If I create the menu at run time how do I associate code with the Click event?
Need to see the code to tell you were, but yes it is possible with an addhandler.

-I hate Microsoft!
-Forever and always forward.
 
To anyone else who is having this problem. I have found a solution that can be used at design time.

1. Create your base ContextMenuStrip.
2. Set ShowImageMargin to false.
3. Create your items that will be on the first level of this Menu.
4. Create another ContextMenuStrip for the subitems of one of the ToolStripMenuItems.
5. Set ShowImageMargin to false on this second Menu.
6. On the properties for your ToolStripMenuItem select the second ContextMenuStrip as the DropDown.

This can be used for multiple levels as seen in the screenshot attached.



-Pete
 
 http://www.team-neg.com/files/pics/contextmenu-imagemargin.png
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top