Click here to Skip to main content
14,241,655 members
Rate this:
Please Sign up or sign in to vote.
See more:
HI all,
I want to customise the context menu for my application,(i.e) I want to add the picture box to the context menu item. how can i do this?
Posted
Updated 19-Sep-10 20:55pm
Comments
Simon_Whale 20-Sep-10 4:25am
   
you need to clarify your question more! are you wanting to add a picture box to the context menu? or fire a context menu from the picture box?
Sandeep Mewara 20-Sep-10 5:30am
   
Apart from what Simon asked, do add what have you tried so far?
krishnakumar_L 20-Sep-10 11:46am
   
i don't want to fire a context menu from the picture box, instead i want to add a picture box to the context menu, we can add a text box in the context menu and it is "toolstiptextbox" , like that way i want to add a picture box inside a context menu item.
krishnakumar_L 20-Sep-10 11:51am
   
hi sandeep first of all tanks for giving a comment, I have trying to customize the context menu. i tried in google and searched in net i cant find any solution for this. i hope some one could help me.
Rate this:
Please Sign up or sign in to vote.

Solution 1

Usually, you don't add a picturebox control to the menu. You owner draw the menu and draw the image you want appropriately.

See this list[^] of articles.
   
Comments
krishnakumar_L 22-Sep-10 3:11am
   
thanks Dave, I too tried that but i cant get good look and feel in that. in one half of the menu item the image is displayed ,and in set the text blank, and also i set the property to show only the image . but still i can see the text area.. but if we can add the picture box there, i thought it could be resolved...
Dave Kreskowiak 22-Sep-10 7:59am
   
This question should not have been posted in Quick Answers. There's too much discussion on it and it's not a good place to post code snippets. Repost this in the forums and post the rendering code you have for the context menu.
Dave Kreskowiak 22-Sep-10 8:00am
   
BTW: In order to put a picturebox on the context menu you have to OwnerDraw the context menu anyway...
Rate this:
Please Sign up or sign in to vote.

Solution 2

i think you should override Paint method.

Private Sub ToolStripMenuItem1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles ToolStripMenuItem1.Paint
  DirectCast(sender, ToolStripMenuItem).DisplayStyle = ToolStripItemDisplayStyle.None
  e.Graphics.DrawImage(My.Resources.attach, 0, 0, e.ClipRectangle.Width, e.ClipRectangle.Height)
End Sub
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100