在列表视图中添加一个复选框(C#) [英] Add a checkbox in a listview (C#)
问题描述
我想在C#应用程序中显示一个列表视图,其中每一行代表一个产品,因此将属性视图设置为详细信息。一个列(最后一个列)应该是一个复选框,因为它表示是否对产品打折。
I'd like to show a listview in a C# application where every row represents a product so the property "view" is set on "detail". One column (the last one) should be a checkbox because it represents if the product is discountinued.
在checkboxes属性设置为true的情况下,第一列中出现一个复选框因此它不适用于我的应用程序。
With the checkboxes property set to true, a checkbox appear in the first column so it doesn't work for my application.
如何将复选框添加到最后一列?谢谢
How can add the checkbox to the last column? Thank you
推荐答案
复选框
始终与第一列。但是,您可以更改列的显示的顺序。
The Checkboxes
are always associated with the first Column. However you change re-order the display of the Columns.
您需要做的所有事情都转到列设计器中,并设置第一个列的 DisplayIndex
到最后一列的索引。
All you need to do it go to the Columns designer and set the 1st colum's DisplayIndex
to the last column's index.
或在代码中完成:
listView1.Columns[0].DisplayIndex = listView1.Columns.Count - 1;
listView1.Invalidate();
请注意 Invalidate
是强制执行所必需的新布局的显示。.
Note the Invalidate
which is necessary to enforce the display of the new layout..
这篇关于在列表视图中添加一个复选框(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!