当按下任何aplha键时,将在列表框的顶部显示项目. [英] show items at the top of list box when any aplha key is pressed.

查看:74
本文介绍了当按下任何aplha键时,将在列表框的顶部显示项目.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在用C#开发一个窗口应用程序.我有一个填写国家名称的列表框.
打开该表格并按G键后,德国国家/地区显示在显示区域的底部.但是我希望它显示在显示区域(列表框)的顶部.

谢谢,

Hi
I am developing a window application in C#. I have a listbox filled with country names.
When that form is opened and a key is pressed say G, the country Germany shows at the bottom of the display area. But i want it to display at the top of the display area( listbox).

Thanks,

推荐答案

在列表框中按键;

In the listbox keypress;

private void listBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    //Find the first item that starts with the keypressed, and set it to the top of the list
        listBox1.TopIndex =listBox1.FindString(e.KeyChar.ToString(), 0);
}


这篇关于当按下任何aplha键时,将在列表框的顶部显示项目.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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