![]() ' This example demonstrates how to apply a Rectangle r = Rectangle.Inflate(e.Item.ContentRectangle, -2, -2) Protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) Using (Pen p = new Pen(ProfessionalColors.SeparatorLight))Į.Graphics.DrawEllipse(p, e.Item.ContentRectangle) Using (Brush b = new SolidBrush(ProfessionalColors.SeparatorLight))Į.Graphics.FillEllipse(b, e.Item.ContentRectangle) Protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) to customize the backgrounds of MenuStrip items and ToolStrip buttons.Ĭlass CustomProfessionalRenderer : ToolStripProfessionalRenderer OnRenderMenuItemBackground and OnRenderButtonBackground methods This type demonstrates a custom renderer. Ts.Renderer = new CustomProfessionalRenderer() Assign the custom renderer to the ToolStrip control only. Ms.Renderer = new CustomProfessionalRenderer() Assign the custom renderer to the MenuStrip control only. ToolStripManager.Renderer = new CustomProfessionalRenderer() Assign the custom renderer at the application level. ToolStripManager.RenderMode = ToolStripManagerRenderMode.Professional Set the default RenderMode to Professional. Ts.RenderMode = ToolStripRenderMode.ManagerRenderMode Ms.RenderMode = ToolStripRenderMode.ManagerRenderMode ToolStrip ts = ToolStripManager.FindToolStrip("ToolStrip") ToolStrip ms = ToolStripManager.FindToolStrip("MenuStrip") ![]() Void applyButton_Click(object sender, EventArgs e) or it applies a custom renderer to the individual MenuStrip or ToolStrip controls, it applies a custom renderer selectively to Depending on the value selected in a ComboBox control, the "Apply Renderers" button is clicked. This is important for correct placement in the z-order. Add the ToolStrip to the form's Controls collection. Create a GroupBox for the TableLayoutPanel control. TableLayoutPanel tlp = new TableLayoutPanel() Create and set up a TableLayoutPanel control. Add the ComboBox control for choosing how Add a Button control to apply renderers.ĪpplyButton.Text = "Apply Custom Renderer" ĪpplyButton.Click += new EventHandler(applyButton_Click) ToolStripMenuItem fileMenuItem = new ToolStripMenuItem("File") į("Save As.") Create a new menustrip with a new window. Create and populate a new ToolStrip control. ToolStrip or to the application as a whole.ĬomboBox targetComboBox = new ComboBox() custom professional renderer to an individual This example demonstrates how to apply a To see custom menu item rendering, select the MenuStrip option from the ComboBox control, click Apply, and then open the File menu item. To use this code example, compile and run the application, and then select the scope of the custom rending from the ComboBox control. The following code example demonstrates how to selectively apply a custom renderer to a ToolStrip control and a MenuStrip control. You can customize the appearance of your ToolStrip controls individually or for all the ToolStrip controls in your application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |