WinForms ComboBox SelectedIndexChanged not firing when typing few chars followed by Alt+Down

前端 未结 5 2046
无人共我
无人共我 2021-02-19 03:21

In short

When I type a character in a ComboBox, press Alt+Down followed by Enter or Tab, the SelectedIndexChanged event doesn\'t fire, even though the S

5条回答
  •  没有蜡笔的小新
    2021-02-19 04:13

    Correct me if I'm wrong. Here is code I've used.

    comboBox1.Items.AddRange(new object[] {
                    "One",
                    "Two",
                    "Three"
    });
    
    comboBox1.SelectedIndexChanged+=(sa,ea)=>
     {
       label1.Text = "Selected index: " + comboBox1.SelectedIndex;
     };
    comboBox1.TextChanged+= (sa, ea) =>
     {
     comboBox1.SelectedIndex = comboBox1.FindStringExact(comboBox1.Text);
    
     //OR
     //comboBox1.SelectedIndex = comboBox1.Items.IndexOf(comboBox1.Text);
      comboBox1.SelectionStart  = comboBox1.Text.Length;
    };
    

提交回复
热议问题