简体   繁体   English

在textBox中输入索引后如何选择listBox的项目c#

[英]how i can selected item of listBox after enter the index in textBox c#

        int index;
        index = int.Parse(txtIndex.Text);
        lstList.SelectedIndex = index;  [enter image description here][1]

when i enter "2" he select the third name in listBox 当我输入“ 2”时,他在listBox中选择第三个名称

You can do this: 你可以这样做:

lstList.SetSelected(index, true);

NOTE: ListBox items are zero index based so be sure that you have the correct input 注意:ListBox项基于零索引,因此请确保您输入正确

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM