使用列表框更改标签文本 [英] Changing label text using listbox
本文介绍了使用列表框更改标签文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在表单1中有一个列表框,当点击下一个按钮时,我希望列表框中的第一个项目成为表单2中的标题(标签中的文本)。
我写了一些代码...
Ops.PgeTitleLbl.Text = CustLB.GetItemText(CustLB.SelectedItem);
这仅适用于选择列表框中的项目,我希望它无需选择项目即可工作。是否可以这样做?
我尝试过:
Ops.PgeTitleLbl.Text = CustLB.GetItemText(0,true);
解决方案
使用 ListBox.Items属性(System.Windows.Forms) [ ^ ]:
Ops.PgeTitleLbl.Text = CustLB.Items [index] .ToString();
I have a listbox in form 1, when the 'next' button is clicked I want the first item in the listbox to become the title (text in the label) in form 2.
I've written some code...
Ops.PgeTitleLbl.Text = CustLB.GetItemText(CustLB.SelectedItem);
This only works if an item in the listbox is selected, I want it to work without needed to select an item. Is it possible to do this?
What I have tried:
Ops.PgeTitleLbl.Text = CustLB.GetItemText(0, true);
解决方案
Use ListBox.Items Property (System.Windows.Forms)[^]:
Ops.PgeTitleLbl.Text = CustLB.Items[index].ToString();
这篇关于使用列表框更改标签文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文