可以有一个多栏ListVIEW控件,其中一列是复选框吗?示例代码或链接将非常感谢。
我正在使用visual studio 2005
最佳答案
Allan Anderson创建了一个自定义控件来允许您执行此操作。
你可以在这里找到它:http://www.codeproject.com/KB/list/aa_listview.aspx
下面是该控件的一些示例代码:
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