打印本文 打印本文 关闭窗口 关闭窗口
c#获取listBox中多选项的索引值
作者:佚名  文章来源:本站原创  点击数1652  更新时间:2012/4/28 11:09:53  文章录入:mintao  责任编辑:mintao

c#获取listBox中多选项的索引值,

C#中有这个功能,但是初学者不容易找到,我写在下面,供参考

 private void button1_Click(object sender, EventArgs e)
        {
         ListBox.SelectedIndexCollection K = listBox1.SelectedIndices;
         foreach (int j in K)
           {
               textBox1.Text += j.ToString() + "\r\n";
           }

你如果选中的是listBox中的第1 、3  、5项,此时textBox1中显示为

0

2

4

          
        }

打印本文 打印本文 关闭窗口 关闭窗口