This is a migrated thread and some comments may be shown as answers.

RadDropDownButton prevent close?

1 Answer 139 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
David A.
Top achievements
Rank 1
David A. asked on 14 Feb 2012, 03:33 AM
Hi,
I have a RadDropDownButton and am using the menum items as a checklist.  The problem is I would like to keep the drop down open until the button is clicked again to allow the user to select multiple items.

Is this possible?

Thank you,
David

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 16 Feb 2012, 08:58 PM
Hi David,

Thank you for writing.

You can achieve the desired functionality by canceling the popup closing in the DropDownClosing event handler of DropDownButtonElement except when a flag raised in the MouseDown event of the DropDownButtonElement is true. Here is a sample:
public Form1()
{
    InitializeComponent();
 
    foreach (RadMenuItem item in radDropDownButton1.Items)
    {
        item.CheckOnClick = true;
    }
 
    radDropDownButton1.DropDownButtonElement.MouseDown += new MouseEventHandler(DropDownButtonElement_MouseDown);
    radDropDownButton1.DropDownButtonElement.DropDownClosing+=new RadPopupClosingEventHandler(DropDownButtonElement_DropDownClosing);
}
 
private bool preventClose = false;
 
void DropDownButtonElement_MouseDown(object sender, MouseEventArgs e)
{
    if (radDropDownButton1.DropDownButtonElement.IsDropDownShown)
    {
        preventClose = true;
    }
}
 
void DropDownButtonElement_DropDownClosing(object sender, RadPopupClosingEventArgs args)
{
    if (preventClose)
    {
        preventClose = false;
        return;
    }
    args.Cancel = true;
}

I hope that you find this information helpful. Should you have any other questions, do not hesitate to contact us.
 
Greetings,
Stefan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
David A.
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or