如何在ListView对象中创建多个复选框?

时间:2011-12-23 16:44:57

标签: c# listview checkbox subitem

我使用的ListWiew已选中已选中的属性,因此第一列中的每个项目都有一个复选框。现在,我想在第二列上有另一个复选框,但在列表视图的属性中找不到任何有用的复选框,以便有多个复选框。

我该怎么做?

1 个答案:

答案 0 :(得分:4)

为什么不使用DataGrid?它可以根据需要和任何地方显示尽可能多的复选框:)

            dataGridView1.ColumnCount = 3;
            dataGridView1.Columns[0].Name = "Product ID";
            dataGridView1.Columns[1].Name = "Product Name";
            dataGridView1.Columns[2].Name = "Product Price";

            string[] row = new string[] { "1", "Product 1", "1000" };
            dataGridView1.Rows.Add(row);
            row = new string[] { "2", "Product 2", "2000" };
            dataGridView1.Rows.Add(row);
            row = new string[] { "3", "Product 3", "3000" };
            dataGridView1.Rows.Add(row);
            row = new string[] { "4", "Product 4", "4000" };
            dataGridView1.Rows.Add(row);

            DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
            dataGridView1.Columns.Add(chk);
            chk.HeaderText = "Check Data";
            chk.Name = "chk";
            dataGridView1.Rows[2].Cells[3].Value = true;