如何获取列表框的第一个索引? [英] how can I get the first index of a listbox ?

查看:291
本文介绍了如何获取列表框的第一个索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:)

如何获得列表框的第一个索引或指定的索引?

例如:

我想将第一个或第二个索引的值作为文本放在文本框中

我该怎么办?

谢谢大家:)

Hi all :)

how can I get the first index or specified index of a list box ?

for example:

I want to put the value of a the first or second index as a text in a textbox

how can I do that ?

thank you all :)

推荐答案



您可以尝试使用此代码在文本框中显示第一个索引值
Hi,

you can try this code for displaying first index value in textbox
 List1.selectedIndex=1;
 textbox1.Text=List1.selectedValue;
List1.selectedIndex=-1;



所有最佳



All the Best


使用Items属性,例如list1.Items[0].
然后将文本框中的文本设置为此值.
Use Items property e.g. list1.Items[0].
Then set the text in the textbox to this value.


用于获取索引i(索引0是第一个):
for getting index i (index 0 is the first one):
myTextbox.Text = myListBox.Items[i].ToString();


这篇关于如何获取列表框的第一个索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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