列表视图控件中的复选框 [英] Checkbox in listview control
本文介绍了列表视图控件中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你能有一个多列列表视图控件,其中一列是一个复选框吗?示例代码或链接将不胜感激.
Can you have a multicolumn listview control where one of the columns is a checkbox? Example code or links would be greatly appreciated.
我使用的是 Visual Studio 2005
I am using visual studio 2005
推荐答案
Allan Anderson 创建了一个自定义控件来让您执行此操作.你可以在这里找到它:http://www.codeproject.com/KB/list/aa_listview.aspx
Allan Anderson created a custom control to let you do this. You can find it here: http://www.codeproject.com/KB/list/aa_listview.aspx
这是该控件的一些示例代码:
Here's some example code for that control:
GlacialList mylist = new GlacialList();
mylist.Columns.Add( "Column1", 100 ); // this can also be added
// through the design time support
mylist.Columns.Add( "Column2", 100 );
mylist.Columns.Add( "Column3", 100 );
mylist.Columns.Add( "Column4", 100 );
GLItem item;
item = this.glacialList1.Items.Add( "Atlanta Braves" );
item.SubItems[1].Text = "8v";
item.SubItems[2].Text = "Live";
item.SubItems[2].BackColor = Color.Bisque;
item.SubItems[3].Text = "MLB.TV";
item = this.glacialList1.Items.Add( "Florida Marlins" );
item.SubItems[1].Text = "";
item.SubItems[2].Text = "Delayed";
item.SubItems[2].BackColor = Color.LightCoral;
item.SubItems[3].Text = "Audio";
item.SubItems[1].BackColor = Color.Aqua; // set the background
// of this particular subitem ONLY
item.UserObject = myownuserobjecttype; // set a private user object
item.Selected = true; // set this item to selected state
item.SubItems[1].Span = 2; // set this sub item to span 2 spaces
ArrayList selectedItems = mylist.SelectedItems;
// get list of selected items
这篇关于列表视图控件中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文