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

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

问题描述

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

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?

即.组合框有项目

  • 乔治亚州亚特兰大
  • 佐治亚州雅典
  • 佛罗里达迈阿密
  • ....

然后用户选择一个,然后他们在框中看到的都是格鲁吉亚"

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 事件发生后调用 select :

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天全站免登陆