We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ParentBarItem and CloseOnClick property

The documentation contains a great example of how this property can be used to create a menu containing BarItems that can be checked.

However, what if I want to mix checkable items with items that behave normally (i.e. they close the menu when they are clicked)?

Below i have extended the example to illustrate my point...

private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
PopupMenu popup = new PopupMenu();
ParentBarItem parentItem = new ParentBarItem();
parentItem.CloseOnClick = false;

barItem1.Checked = true;
barItem1.Click += new EventHandler(ItemChecked);
barItem2.Click += new EventHandler(ItemClicked);

parentItem.Items.Add(barItem1);
parentItem.Items.Add(barItem2);

popup.ParentBarItem = parentItem;
popup.Show(this, new Point(e.X, e.Y));
}
private void ItemChecked(object sender, EventArgs e)
{
BarItem itemClicked = sender as BarItem;
itemClicked.Checked = !itemClicked.Checked;
}
private void ItemClicked(object sender, EventArgs e)
{
// Perform Action...

// CLOSE MENU ?
}

5 Replies

GR Golda Rebecal Syncfusion Team February 28, 2007 02:28 PM UTC

Hi Nik,

We can use the Hide method of the PopupMenu to avoid showing the popup after an item is clicked.

Please have a look at the attached sample and let me know if this meets your requirement.

Thanks for your interest in Syncfusion products.

Best Regards,
Golda

CS52.zip


NI Nik March 1, 2007 10:46 PM UTC

Thanks for your example. Unfortunately it doesn't solve my problem :(

I should have been more explicit - the BarItems on which I require this behaviour are part of a ChildFrameBarManager. So they are shown via a MENU or a TOOLBAR rather than a PopupMenu.

Thanks for your continued assistance.

Nik


GR Golda Rebecal Syncfusion Team March 5, 2007 02:31 PM UTC

Hi Nik,

With the current implementation, when we set the CloseOnClick property to false for a parentbaritem that is hosted on a main menu or toolbar, it is not possible to close the popup menu.

Please let me know if you have any other questions.

Thanks for your interest in Syncfusion products.

Best Regards,
Golda


GR Golda Rebecal Syncfusion Team March 12, 2007 11:49 AM UTC

Hi Nik,

Sorry for the wrong update that I posted earlier.

It is possible to close the popup menu when a particular child baritem is clicked and not for other by using the CloseOnClick property of the ParentBarItem.

Please have a look at the attached sample and let me know if you need any further assistance.

Thanks for your interest in syncfusion products.

XPMenu

Best Regards,
Golda


NI Nik March 29, 2007 07:43 PM UTC

That's great! Thanks for your help

Loader.
Live Chat Icon For mobile
Up arrow icon