为什么我的ListViewItem无法在c#类ListView中编辑

时间:2012-06-17 10:16:52

标签: c# listview

我试图在MSDN上找到答案但却失败了。

这是我的代码:

        ListView listView1 = new ListView();
        listView1.Bounds = new Rectangle(new Point(10, 10), new Size(300, 200));

        listView1.View = View.Details;
        listView1.LabelEdit = true; //set here
        listView1.AllowColumnReorder = true;
        listView1.CheckBoxes = true;
        listView1.FullRowSelect = true;
        listView1.GridLines = true; // show as grid
        listView1.Sorting = SortOrder.Ascending;

这只能让我编辑列表视图的第一列。因为只有第一列是每个列表视图项的标签。

我想要做的是编辑每个网格(列表视图项)。任何好的建议?

1 个答案:

答案 0 :(得分:0)

试试:

ListView listView1 = new ListView();
listView1.View = View.Details;
listView1.LabelEdit = true;
listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left);
listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left);
listView1.Items.AddRange(new ListViewItem[]{"",""});
listView1.Items.AddRange(new ListViewItem[]{"",""});
.
. (how many items you want to edit)