|
-
Aug 1st, 2003, 02:25 PM
#1
Thread Starter
Junior Member
ListView : Finding out what line has been checked
Hi,
Is there anyway to find out what line the user has just checked in a ListView control with check boxes?
I can tell they've checked something, and I can get an enumerator of all the checked items, but I need to know which specific item was checked at the time that it's checked.
Thanks in advance,
Liam.
-
Aug 11th, 2003, 02:55 PM
#2
Addicted Member
VB Code:
Dim myItem As ListViewItem
Dim myChecked As ListView.CheckedListViewItemCollection
myChecked = ListView1.CheckedItems
For Each myItem In myChecked
'do something
Next
-
Aug 11th, 2003, 03:08 PM
#3
or easier still ....
VB Code:
[COLOR=blue]Dim[/color] lvItem [COLOR=blue]As[/color] ListViewItem
[COLOR=blue]For Each[/color] lvItem [COLOR=blue]In[/color] ListView1.CheckedItems
MessageBox.Show(lvItem.Text)
[COLOR=blue]Next[/color]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Aug 11th, 2003, 03:12 PM
#4
oops i think we missread what you want, you only want to check the item that gets checked ( so to speak )
VB Code:
[COLOR=BLUE]Private[/COLOR] [COLOR=BLUE]Sub[/COLOR] ListView1_ItemCheck([COLOR=BLUE]ByVal[/COLOR] sender [COLOR=BLUE]As[/COLOR] [COLOR=BLUE]Object[/COLOR], [COLOR=BLUE]ByVal[/COLOR] e [COLOR=BLUE]As[/COLOR] System.Windows.Forms.ItemCheckEventArgs) [COLOR=BLUE]Handles[/COLOR] ListView1.ItemCheck
[COLOR=BLUE]Dim[/COLOR] lvItem [COLOR=BLUE]As[/COLOR] ListViewItem = [COLOR=BLUE]DirectCast[/COLOR](sender, ListViewItem)
MessageBox.Show(lvItem.Text & " you just checked this item!")
[COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub[/COLOR]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Aug 12th, 2003, 06:39 AM
#5
Thread Starter
Junior Member
Nice and simple code! I'll give it a go.
Thanks for the help!
Best regards,
Liam.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|