组合框专注于选择后的文本开头 [英] combobox focus on beginning of text after selection

查看:56
本文介绍了组合框专注于选择后的文本开头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有组合框的Winforms,该组合框的下拉宽度大于其大小。当用户从那里选择某项内容时,它仅显示文本的结尾而不是开头。我该如何默认显示以字符串开头的文本?

I'm using winforms with a combobox that has a wider drop down width than it's size. when a user selects something from there, it displays just the ending of the text instead of the beginning. how do i default it to show text starting with the start of the string?

ie。组合框有项目


  • 亚特兰大乔治亚州

  • 雅典乔治亚州

  • 佛罗里达州迈阿密

  • ....

  • Atlanta Georgia
  • Athens Georgia
  • Miami Florida
  • ....

,用户选择了一个他们看到的东西之后的框中是佐治亚州

and the user picks one and all they see in the box afterwards is "a Georgia"

不,我不幸地没有使组合框变大的属性,并且列表中单词的顺序赢得了

no, i unfortunately don't have the realestate to make the combobox bigger, and the order of the words in the list won't be changed.

谢谢!

推荐答案

调用SelectedIndexChanged事件之后的

The trick is to call the select after the SelectedIndexChanged event happens:

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) {
  this.BeginInvoke(new Action(() => { comboBox1.Select(0, 0); }));
}

这篇关于组合框专注于选择后的文本开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆