C#listbox用法

1. 属性列表:

    SelectionMode    组件中条目的选择类型,即多选(Multiple)、单选(Single)
    Rows             列表框中显示总共多少行
    Selected         检测条目是否被选中
    SelectedItem     返回的类型是ListItem,获得列表框中被选择的条目
    Count            列表框中条目的总数
    SelectedIndex    列表框中被选择项的索引值
    Items            泛指列表框中的所有项,每一项的类型都是ListItem

2. 取列表框中被选中的值

     ListBox.SelectedValue

3. 动态的添加列表框中的项:

     ListBox.Items.Add("所要添加的项");

4. 移出指定项:

     //首先判断列表框中的项是否大于0
     If(ListBox.Items.Count > 0 )
     {
//移出选择的项
ListBox.Items.Remove(ListBox.SelectedItem);
     }

<

你可能感兴趣的:(C#,C#,listbox)