How to have a split button show context menu only when the split part is clicked?

749 views Asked by At

I have found many question concerning split buttons, but I need clarification. I am using a Wisej split button. The following code will show a context menu to the bottom left of the button part(left-side of the split button which has button text) of a split button.

private void splitButton1_Click(object sender, EventArgs e)
    {
        Button btnSender = (Button)sender;
        Point ptLowerLeft = new Point(-20, btnSender.Height);
        ptLowerLeft = btnSender.PointToScreen(ptLowerLeft);
        contextMenu1.Show(ptLowerLeft);           
    }

I want to know is how to have a context menu show only when the split part (i.e. the small section on the right-side of the split button with an arrow icon) of the split button is clicked and not on the button side.

1

There are 1 answers

0
Luca-ITG On

You don't need to use a context menu object simply add the menu items to the SplitButton.MenuItems collection. You'll get a Click event when clicking on the button and an ItemClicked event when clicking on a menu item. The menu items will show only when clicking on the split part of the button.

When adding MenuItems to a Button (instead of a SplitButton) the menu will always show when clicking on the button.

The latest release added the Orientation property to SplitButton to show the split part below the button when set to Vertical.

HTH. Sorry for the late reply.