문제

열 중 하나가 확인란인 다중 열 목록 보기 컨트롤을 가질 수 있습니까?예제 코드나 링크를 주시면 감사하겠습니다.

저는 비주얼 스튜디오 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

다른 팁

그리드 보기 컨트롤을 사용하는 것이 더 좋지만 원하는 경우 오직 체크박스가 있는 열 하나와 그 열은 첫 번째 그냥 쓸 수 있는 것:

this.listView1.CheckBoxes = true;

아래와 같이 체크박스 열을 추가합니다.

myListView.CheckBoxes = true;
myListView.Columns.Add(text, width, alignment);

아래와 같이 ListViewItem 을 추가하세요.

ListViewItem lstViewItem = new ListViewItem();
lstViewItem.SubItems.Add("Testing..");
lstViewItem.SubItems.Add("Testing1..");

myListView.Items.Add(lstViewItem);

왜 노력하지 않니? Mathew Hall의 XPTable

아마도 ListView.Checkboxes.

다음을 설정할 수 있습니다. CheckBoxes 재산 true.코드에서는 다음과 같이 수행할 수 있습니다.

listView1.CheckBoxes = true;

대신 그리드 보기를 사용할 수 있습니다. 그러면 열 내용을 더 세밀하게 제어할 수 있습니다.

당신은 시도 할 수 있습니다 TreeViewAdv.오픈 소스이며 sourceforge에서 호스팅됩니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top