Click here to Skip to main content
12,405,932 members (60,029 online)
Click here to Skip to main content
Add your own
alternative version

Stats

89.7K views
1.6K downloads
39 bookmarked
Posted

Checkable Detail List View

, 3 Apr 2003
Rate this:
Please Sign up or sign in to vote.
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 setthe 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

Share

About the Author

No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralSimpler way to get row and column Pin
Andrew Phillips31-Oct-07 19:04
memberAndrew Phillips31-Oct-07 19:04 
GeneralSelect All Question Pin
sho_nufff10-Aug-05 4:08
membersho_nufff10-Aug-05 4:08 
GeneralProgress Bar in ListView Pin
Bluetears21-Sep-03 4:18
memberBluetears21-Sep-03 4:18 
GeneralListview color and grid Pin
ksjanjua18-Sep-03 22:06
memberksjanjua18-Sep-03 22:06 
GeneralQuestion... Pin
mikasa7-Apr-03 2:22
membermikasa7-Apr-03 2:22 
GeneralRe: Question... Pin
Tomislav Petrovic [per0]7-Apr-03 2:35
memberTomislav Petrovic [per0]7-Apr-03 2:35 
GeneralRe: Question... Pin
mikasa7-Apr-03 2:47
membermikasa7-Apr-03 2:47 
GeneralInteresting details... Pin
.S.Rod.4-Apr-03 18:54
member.S.Rod.4-Apr-03 18:54 
GeneralRe: Interesting details... Pin
Paul Selormey4-Apr-03 19:42
memberPaul Selormey4-Apr-03 19:42 
GeneralRe: Interesting details... Pin
.S.Rod.4-Apr-03 19:55
member.S.Rod.4-Apr-03 19:55 
GeneralRe: Interesting details... Pin
Paul Selormey4-Apr-03 20:12
memberPaul Selormey4-Apr-03 20:12 

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

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

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