Skip to content

Commit 368f118

Browse files
authored
Merge pull request #650 from telerik/new-kb-add-vertical-separator-radmenu-winforms-4a6c115d27c74aceb58ef41ac8b23632
Added new kb article add-vertical-separator-radmenu-winforms
2 parents f6bbed7 + 54d942a commit 368f118

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
![WinForms RadMenu Vertical Separator](images/add-vertical-separator-radmenu-winforms001.png)
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)
1.13 KB
Loading

0 commit comments

Comments
 (0)