To adjust just a few aspects of how an item is painted, you typically override the ToolStripRenderer. The event arguments for these methods expose several properties such as rectangles, colors, and text formats that you can adjust as desired. The ToolStrip controls also provide finer access to the rendering of the items and container through the ToolStripRenderer class, which has overridable methods for painting the background, item background, item image, item arrow, item text, and border of the ToolStrip. The Paint event and OnPaint method for a ToolStripItem behave like other control paint events. As with regular painting, the coordinate system is relative to the client area of the control that is, the upper left-hand corner of the control is 0, 0. As with other Windows Forms controls, the ToolStrip and ToolStripItem both have overridable OnPaint methods and Paint events. You can do custom painting in ToolStrip controls in several ways. The following topics describe features and behavior that are generic to the ToolStrip and derived controls. They are available by default at design time for the ContextMenuStrip control: The following items are specifically designed to work seamlessly with both ToolStripSystemRenderer and ToolStripProfessionalRenderer in all orientations. ContextMenuStrip supports images, menu-item check state, text, access keys, shortcuts, and cascading menus. ContextMenuStrip supports cancelable Opening and Closing events to handle dynamic population and multiple-click scenarios. You can show a ContextMenuStrip programmatically by using the Show method. You can associate a ContextMenuStrip with any control, and a right mouse click automatically displays the context menu (or shortcut menu). They are available by default at design time for the StatusStrip control:ĬontextMenuStrip replaces ContextMenu. Special features of StatusStrip include a custom table layout, support for the form's sizing and moving grips, and the Spring property, which allows a ToolStripStatusLabel to fill available space automatically. StatusStrip replaces the StatusBar control. They are available by default at design time for the MenuStrip control: Functionally, ToolStripDropDownItem and ToolStripMenuItem work along with MenuStrip, although they are derived from ToolStripItem. It also provides key handling and multiple document interface (MDI) features. MenuStrip is the top-level container that supersedes MainMenu. They are available by default at design time for the ToolStrip control: These are the items that are not currently in an overflow menu. In a class derived from ToolStrip, you can also use the DisplayedItems property to access only those items that are currently displayed. You can access all the items in a ToolStripDropDownItem through the DropDownItems collection. You can access all the items in a ToolStrip through the Items collection. The following object model shows the ToolStrip inheritance hierarchy. ToolStrip is the abstract base class for MenuStrip, StatusStrip, and ContextMenuStrip. The following topics describe ToolStrip and the controls that derive from it. These classes are all contained in the namespace and they are all typically named with the "ToolStrip" prefix (such as ToolStripOverflow) or with the "Strip" suffix (such as MenuStrip). The ToolStrip and ToolStripItem classes provide a flexible, extensible system for displaying toolbar, status, and menu items.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |