将一个CheckBox在ListViewSubItem [英] Place a CheckBox in a ListViewSubItem
问题描述
我试图创建具有6列一个WinForms ListView控件。前两列将在他们的文字,但我想最后的四列有一个复选框在其中。
I'm trying to create a WinForms ListView control with 6 columns. The first two columns will have text in them, but I want the last four columns to have a checkbox in them.
我知道如何添加带文本的ListViewSubItem(这样做第二列),但你怎么插入一个复选框?
I know how to add a ListViewSubItem with text (did this for the second column), but how do you insert a CheckBox?
推荐答案
ListView控件不支持这一点。只有第一列可以有一个复选框。你可以伪造其与自定义绘制和鼠标点击测试,但是这是一个大量的工作。考虑使用一个DataGridView来代替。您可以将列类型更改为DataGridViewCheckBoxColumn。
ListView doesn't support this. Only the 1st column can have a checkbox. You could fake it with custom drawing and mouse hit testing but that's a lot of work. Consider using a DataGridView instead. You can change the column type to DataGridViewCheckBoxColumn.
这篇关于将一个CheckBox在ListViewSubItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!