【问题标题】:How to Add value in the list box from another list box in window Application如何从窗口应用程序中的另一个列表框中添加列表框中的值
【发布时间】:2014-05-19 14:00:35
【问题描述】:

我正在 Visual Studio 2012 中做一个 Windows 应用程序,因为我在列表框中有一些名称列表。现在我需要选择这些名称并需要通过单击添加按钮添加到另一个列表框中。如果单击“删除”按钮,我还需要从第二个列表框中删除,并且名称必须再次返回主列表框。

【问题讨论】:

标签: c#


【解决方案1】:

使用 ListBox 属性获取选定项--

ListBox.SelectedItem

或循环(如果列表框选择模式设置为多选)

ListBox.SelectedItems

删除项目的方法--

ListBox.Items.Remove(obj)

ListBox.Items.RemoveAt(index)

添加项目的方法--

ListBox.Items.Add(obj)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多