Combobox closes before i can select a checkbox

204 Views Asked by At

I'm currently working in VS 2012. .NET 4.5 and working on an mmc snap-in. (i know right?!)

so i followed this topic:

Is there a simple way to implement a Checked Combobox in WinForms

as i want something similar to the scheduled task manager.

But that solution does not seem to work for me. the listview pops up but when i try to click on a checkbox in my listview. It gives me a big middle finger and closes my dropdown.

is there any way i can suppress the combobox's "focus lost" close event? i can, not hide the list but then it never hides.

For Example:

// designer class


// 
// comboBox1
// 
this.comboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.comboBox1.DropDownHeight = 1;
this.comboBox1.DropDownWidth = 1;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.IntegralHeight = false;
this.comboBox1.Location = new System.Drawing.Point(256, 371);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(238, 21);
this.comboBox1.TabIndex = 5;
this.comboBox1.DropDown += new System.EventHandler(this.comboBox1_DropDown);
this.comboBox1.DropDownClosed += new System.EventHandler(this.comboBox1_DropDownClosed);
// 
// lstWeekDays
// 
this.lstWeekDays.CheckBoxes = true;
this.lstWeekDays.Location = new System.Drawing.Point(50, 63);
this.lstWeekDays.Name = "lstWeekDays";
this.lstWeekDays.Size = new System.Drawing.Size(263, 97);
this.lstWeekDays.TabIndex = 13;
this.lstWeekDays.Tag = "lstlstWeekDays";
this.lstWeekDays.UseCompatibleStateImageBehavior = false;
this.lstWeekDays.View = System.Windows.Forms.View.SmallIcon;
this.lstWeekDays.Visible = false;

// Code behind

public Form1()
{
    InitializeComponent();
    this.lstWeekDays.Items.Add("Monday");
    this.lstWeekDays.Items.Add("Tuesday");
    this.lstWeekDays.Items.Add("Wednesday");
    this.lstWeekDays.Items.Add("Thursday");
    this.lstWeekDays.Items.Add("Friday");
    this.lstWeekDays.Items.Add("Saturday");
    this.lstWeekDays.Items.Add("Sunday");
}

private void comboBox1_DropDown(object sender, EventArgs e)
{
    lstWeekDays.Visible = true;
}

private void comboBox1_DropDownClosed(object sender, EventArgs e)
{
    lstWeekDays.Visible = false;
}

Add the checkboxes to this list instead of the panel.

0

There are 0 best solutions below