开发者

Dropped down in combo after focused

I have a combo box. It must display its content, when focused and its value changed as well. I wrote this code in its Value Change event:

if(combo1.Focused) combo1.DroppedDown=true;

But it doesn't work!

what's your solut开发者_运维技巧ion?


What Event handler are you putting that code in? Assuming that you want to show the drop down when the user types in the edit box part of the combo just handle the TextChanged event and put that code inside there and it should work.


If I understand your requirement correctly, when the combobox gets focus you want the drop down list to show. That can be achieved as follows

private void Form1_Load(object sender, EventArgs e)
{
  comboBox1.GotFocus += new EventHandler(comboBox1_GotFocus);
}

void comboBox1_GotFocus(object sender, EventArgs e)
{
  comboBox1.DroppedDown = true;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜