【问题标题】:CheckBox inside a listbox in windows form [duplicate]Windows形式的列表框中的复选框[重复]
【发布时间】:2013-01-11 11:23:36
【问题描述】:

可能重复:
CheckBox inside ListBox
How to insert a check box inside a list box in C#?

我想在应用程序的窗口中的列表框中添加复选框。

这是我的代码:

CheckBox cb = new CheckBox();
while (dr.Read())
{

    listBox1.Items.Add(String.Format("{0} {1}",cb,dr["Stu_Name"]));
}

但是,它没有产生预期的结果。

我想要的是数据读取器的每个列值之前的复选框?有什么建议吗?

【问题讨论】:

    标签: c# .net windows-applications


    【解决方案1】:

    简而言之:您需要使用CheckedListBox Control (Windows Forms)

    以下是 Windows 窗体应用程序的示例代码:

    private void Form1_Load(object sender, EventArgs e)
        {
            var items = checkedListBox1.Items;
            items.Add("Perls");
            items.Add("Checked", true);
        }
    

    【讨论】:

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