【问题标题】:How to handle Events in CheckedListBox in C#?如何在 C# 中处理 CheckedListBox 中的事件?
【发布时间】:2015-07-09 05:40:07
【问题描述】:

我是C# 的新手。当单击CheckedListBox 中的项目时,我尝试执行活动。我试过 private void CheckedListBox1_ItemCheck(Object sender, ItemCheckEventArgs e) { } 但没有任何工作。现在请任何人告诉如何在MessageBox 中显示选中的项目文本?提前致谢。

【问题讨论】:

标签: c# checkedlistbox


【解决方案1】:
        private void button1_Click(object sender, EventArgs e)
    {
        foreach (var item in checkedListBox1.CheckedItems)
        {
            MessageBox.Show(item.ToString()); //This gets the displayed name of the checked items
        }
        foreach (var item in checkedListBox1.CheckedIndices)
        {
            MessageBox.Show(item.ToString()); //This Displays the index of the checked items
        }
    }

如果你检查一个项目,这就是运行的方法。

        private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
    {

    }

这能回答你的问题吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 2020-07-05
    • 2013-07-04
    • 2017-02-04
    • 2012-06-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多