12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
编程知识 时间:2024-11-20 12:50:53
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
要获取用户在ListBox中选定的值,可以通过SelectedIndex属性来获取选定项的索引,并通过Items集合来获取选定项的值。示例代码如下:// 获取ListBox中选定项的索引int selectedInd
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
要获取用户在ListBox中选定的值,可以通过SelectedIndex属性来获取选定项的索引,并通过Items集合来获取选定项的值。示例代码如下:
// 获取ListBox中选定项的索引int selectedIndex = listBox1.SelectedIndex;// 获取选定项的值string selectedValue = listBox1.Items[selectedIndex].ToString();// 输出选定项的值Console.WriteLine(selectedValue);
在上面的代码中,假设listBox1是一个ListBox控件,通过SelectedIndex属性获取用户选定项的索引,然后通过Items集合获取该索引对应的项的值,最后输出选定项的值。
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19