|
| 1 | +--- |
| 2 | +title: Adding a Vertical Separator to RadMenuItem in RadMenu for WinForms |
| 3 | +description: Learn how to insert a vertical separator between menu items in RadMenu for WinForms applications. |
| 4 | +type: how-to |
| 5 | +page_title: How to Insert a Vertical Separator in RadMenu for WinForms |
| 6 | +slug: add-vertical-separator-radmenu-winforms |
| 7 | +tags: menus,radmenu, winforms, separator, menuitem, vertical |
| 8 | +res_type: kb |
| 9 | +ticketid: 1668864 |
| 10 | +--- |
| 11 | + |
| 12 | +## Environment |
| 13 | + |
| 14 | +|Product Version|Product|Author| |
| 15 | +|----|----|----| |
| 16 | +|2024.4.1113|RadListView for WinForms|[Dinko Krastev](https://www.telerik.com/blogs/author/dinko-krastev)| |
| 17 | + |
| 18 | +## Description |
| 19 | + |
| 20 | +In the following example, we will demonstrate how you can add a vertical separator in the RadMenu control. |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +## Solution |
| 25 | + |
| 26 | +To add a vertical separator to a RadMenu, use the `RadMenuSeparatorItem` class. You can customize the separator's orientation. The following code snippet demonstrates how to insert a vertical separator item between RadMenuItems upon form load. Ensure to adjust the index in the `Items.Insert` method according to where you want to place the separator in your menu. |
| 27 | + |
| 28 | +````C# |
| 29 | +private void Form1_Load(object sender, EventArgs e) |
| 30 | +{ |
| 31 | + var menuSeparatorItem = new Telerik.WinControls.UI.RadMenuSeparatorItem(); |
| 32 | + |
| 33 | + menuSeparatorItem.Name = "myPanel_Menu_Sep1"; |
| 34 | + menuSeparatorItem.SeparatorOrientation = Telerik.WinControls.SepOrientation.Vertical; |
| 35 | + menuSeparatorItem.BackColor = Color.Red; |
| 36 | + menuSeparatorItem.ShouldPaint = true; |
| 37 | + menuSeparatorItem.TextVisibility = Telerik.WinControls.ElementVisibility.Visible; |
| 38 | + radMenu1.Items.Insert(1, menuSeparatorItem); |
| 39 | +} |
| 40 | +```` |
| 41 | + |
| 42 | +This approach allows you to dynamically add a vertical separator to your RadMenu, enhancing the menu's visual structure and organization. |
| 43 | + |
| 44 | +## See Also |
| 45 | + |
| 46 | +- [RadMenu Overview](https://docs.telerik.com/devtools/winforms/controls/menu/radmenu/overview) |
| 47 | +- [RadMenuSeparatorItem Class](https://docs.telerik.com/devtools/winforms/api/telerik.wincontrols.ui.radmenuseparatoritem) |
0 commit comments