Click here to Skip to main content
Licence 
First Posted 3 Apr 2003
Views 80,285
Bookmarked 37 times

Checkable Detail List View

By | 3 Apr 2003 | Article
ListView which supports checkable subitems and returns the clicked subitem

Introduction

When user clicks some content in the ListViewDetail, it returns the row and column indexes of the clicked subitem. This control supports checked subitems through AddCheckedSubItem, SetCheck and IsChecked methods. There is also a routine for iterative coloring of the control included in the TPLib.Misc namespace.

Background

When using the Windows Forms ListView control, you have no way to find which subitem the user has clicked or to have checkable subitems, so I've developed ListViewDetail.

Using the code

Control behaves much like an ordinary ListView. The only difference is in the following methods:

AddCheckedSubItem - adds a checked subitem to ListViewItem

ListViewItem lvi = new ListViewItem();
lvi.Text = "Some text";
listView1.AddCheckedSubItem( lvi, true );
listView1.AddCheckedSubItem( lvi, false );
listView1.AddCheckedSubItem( lvi, true );
listView1.Items.Add( lvi );
SetCheck - sets the check in the subitem to true/false
listView1.SetCheck( listViewItem, colIndex, true );
IsChecked - returns the check state of the subitem
listView1.IsChecked( listViewItem.SubItems[5] )

There is also a class named ListViewOperations which contains two static methods, IterateColors( ListView lv, Color color1, Color color2 ) and IterateColors( ListView lv ) which iteratively set the ListView items' background colors.

IterateColors( lv, Color.White, Color.WhiteSmoke );

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Tomislav Petrovic [per0]



Croatia Croatia

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralSimpler way to get row and column PinmemberAndrew Phillips19:04 31 Oct '07  
GeneralSelect All Question Pinmembersho_nufff4:08 10 Aug '05  
GeneralProgress Bar in ListView PinmemberBluetears4:18 21 Sep '03  
GeneralListview color and grid Pinmemberksjanjua22:06 18 Sep '03  
GeneralQuestion... Pinmembermikasa2:22 7 Apr '03  
GeneralRe: Question... PinmemberTomislav Petrovic [per0]2:35 7 Apr '03  
GeneralRe: Question... Pinmembermikasa2:47 7 Apr '03  
GeneralInteresting details... Pinmember.S.Rod.18:54 4 Apr '03  
GeneralRe: Interesting details... PinmemberPaul Selormey19:42 4 Apr '03  
GeneralRe: Interesting details... Pinmember.S.Rod.19:55 4 Apr '03  
GeneralRe: Interesting details... PinmemberPaul Selormey20:12 4 Apr '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 4 Apr 2003
Article Copyright 2003 by Tomislav Petrovic [per0]
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid