Nevron Forum
Home
»
Nevron Vision for NET
»
Nevron User Interface for .NET
»
Checkable drop down menu
Login
Register
Login
Register
Home
»
Nevron Vision for NET
»
Nevron User Interface for .NET
»
Checkable drop down menu
Checkable drop down menu
Post Reply
Checkable drop down menu
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
Goto Topics Forum
Author
Message
Jobelle Firme
Jobelle Firme
posted 5 Years Ago
ANSWER
Topic Details
Group: Forum Members
Posts: 8,
Visits: 65
Hi. How do you create a drop down menu with checkable items but only one item can be selected? Right now I have multiple items can be checked. Thanks!
Reply
Like
0
Nevron Support
Nevron Support
posted 5 Years Ago
ANSWER
Post Details
Group: Administrators
Posts: 3.1K,
Visits: 4.2K
Hi,
To have only one menu item of a drop down menu checked, you can subscribe to the
MouseDown
event of the menu items collection and uncheck all but the clicked menu item in the event handler.
Here's how to create a simple drop down menu:
NMenuDropDown menu = new NMenuDropDown("Menu");
menu.Items.Add(new NCheckableMenuItem("Item 1"));
menu.Items.Add(new NCheckableMenuItem("Item 2"));
menu.Items.Add(new NCheckableMenuItem("Item 3"));
menu.Items.Add(new NCheckableMenuItem("Item 4"));
menu.Items.MouseDown += OnMenuItemsMouseDown;
Here's how to uncheck all but the clicked menu item in the event handler:
private void OnMenuItemsMouseDown(NMouseButtonEventArgs arg)
{
// Get the menu items and the clicked menu item
NMenuItemCollection menuItems = (NMenuItemCollection)arg.CurrentTargetNode;
NCheckableMenuItem clickedMenuItem = arg.TargetNode is NCheckableMenuItem ?
(NCheckableMenuItem)arg.TargetNode :
arg.TargetNode.GetFirstAncestor<NCheckableMenuItem>();
// Uncheck all but the clicked menu item
for (int i = 0; i < menuItems.Count; i++)
{
NCheckableMenuItem currentItem = menuItems[i] as NCheckableMenuItem;
if (currentItem != clickedMenuItem)
{
currentItem.Checked = false;
}
}
}
Best Regards,
Nevron Support Team
Reply
Like
0
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Post Reply
Similar Topics
Post Quoted Reply
Reading This Topic
1 active, 1 guest, 0 members, 0 anonymous
No members currently viewing this topic!
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search