【发布时间】:2023-03-15 02:38:01
【问题描述】:
我正在使用ListWiew,它已选中选中的属性,因此它在第一列的每个项目上都有一个复选框。现在,我还想在第二列上有另一个复选框,但在我的列表视图的属性中找不到任何有用的复选框。
我该怎么做?
【问题讨论】:
-
ListView 不支持。任何网格控件都可以。
标签: c# listview checkbox subitem
我正在使用ListWiew,它已选中选中的属性,因此它在第一列的每个项目上都有一个复选框。现在,我还想在第二列上有另一个复选框,但在我的列表视图的属性中找不到任何有用的复选框。
我该怎么做?
【问题讨论】:
标签: c# listview checkbox subitem
为什么不使用 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;
【讨论】: