0
votes

I have implemented a combo box which has a check box in it (Windows Form Application). This works perfectly fine.

Used: C#, Visual Studio 2010.

Problem: Problem with my combobox is that the dropdown closes after every selection.

Question: Is it any way possible that The drop down remains fixed till I select the multiple items?

Just wanted to know if there is a way to do this.

Thank you.

3
WinForms, WPF, or others? Please add a tag.Olivier Jacot-Descombes
How do you envision the user communicating they are done selecting? The idea violates a few accepted user conventions of the combo box - and would be better served with a custom solution (popping up a CheckListBox on a dialog or small form, for example).John Arlen
@JohnArlen For an example look-and-feel you can look at Windows Explorer or Excel.Ian Boyd

3 Answers

0
votes

I think Wpf extended toolkit CheckComboBox is exactly what you try to do. See following link for more info.

You can add this wpf control in your winform

http://wpftoolkit.codeplex.com/wikipage?title=CheckComboBox&referringTitle=Home

0
votes

Assuming you are working with Winforms:

public class CheckComboBox : ComboBox
{
    Timer _timer = new Timer();

    public CheckComboBox()
    {
        _timer.Interval = 1;
        _timer.Tick += timer_Tick;      
    }
    protected override void OnDropDownClosed(EventArgs e)
    {
        base.OnDropDownClosed(e);
        if (checkbox has been clicked) {
            _timer.Start();
        }
    }

    void timer_Tick(object sender, EventArgs e)
    {
        _timer.Stop();
        DroppedDown = true; // Reopens dropdown.
    }
}
0
votes

You can stop the combo box from closing if you prevent your check boxes from gaining focus when they are clicked.

To do this you need to derive from the CheckBox class and and override the control flags in the constructor:

SetStyle(ControlStyles.Selectable, false);