Two days back, I was thinking on what to post next. So I was playing with VisualStudio for a while looking for the controls that I can learn and tell you about. Then I saw the ContextMenuStrip. As usual I don’t want the VS to create the control for me. So I went to the designer and started to create an object of ContextMenu (Oops. Did I misspell ??). No. I was correct. There are two menus. One is ContextMenu and the other is ContextMenuStrip. So I googled for the difference between them but I hardly found something related to that. (Now I have a nice topic to blog about !!). Lets peep in to the difference between them and the functionalities they provide.
The ContextMenu
This can be found under System.Windows.Forms.ContextMenu. This is a derivative of the class called Menu. This is the usual context menu that you see when you right click in any Notepad window (in early releases of windows). This looks very blunt. Not much of a functionalities were provided for this control. This control exists just for backward compatiability. You can add text to the menu and get notified when they were clicked by the users.
The ContextMenuStrip
This can be found under System.Windows.Forms.ContextMenuStrip. This is a derivative of the class called Control. This is the flashy one that you see when you right click on MS Word or any other MS products. This is the later one and it has many functionalities like,
- You can have images (icons) against each and every menu item
- You can have checkboxes against each and every menu item
- You can disable items (unlike the ComboBoxes where we do it manually like this one)
- You can change the way it is rendered in the screen using the RenderMode property
- You can be notified with many events like, when the menu pops up, checked state changed, clicked, double clicked, item has been added, etc.
- You can toggle showshadow under the menu and more …
Ok. Now how to use all these ?? I will post it next.
