列表框文字 [英] listbox text

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

问题描述

我有一个列表框,其中没有像xxxx,yyyy,zzzzz那样逐行显示的项目.....我怎么能让任何人知道的列表框文本帮助我

i ve one list box that items not having line by line having like xxxx,yyyy,zzzzz.....how can i get that listbox text can any body know help me

推荐答案

这是因为Listbox不会直接公开"Text"属性.

您需要访问为:myListBox.SelectedItem.Text
我发现有一篇很好的文章可以在这里使用: ListBox控件概述 [ ^ ]

在您的情况下,只有一个项目,如果选中了该项目,则可以从selecteditem属性中获取它.如果未选择它,但您仍要访问它,则使用具有正确索引的项目属性.

在这里查看列表框属性 [ ^ ]暴露.

更新:
Listbox.Text将为您提供列表的选定值".看起来好像什么都没有选择,因此您什么也没得到.在这种情况下,您需要像上面提到的那样遍历项目和索引.
This is because Listbox does not expose a ''Text'' property directly.

You need to access as: myListBox.SelectedItem.Text
I found a good article to exaplin it''s use here: ListBox Control Overview[^]

In your case, there is only one item and if selected then the way to get it is from selecteditem property. In case it''s not selected and yet you want to access it then use item proerty with proper index.

Have a look here for all details of listbox properties[^] exposed.

UPDATE:
Listbox.Text would give you ''Selected Value'' of the list. It looks like nothing is selected and thus you are not getting anything. In that case, you need to go via item and index as I mentioned above.


这篇关于列表框文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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