|
-
May 19th, 2010, 09:35 AM
#1
Thread Starter
Addicted Member
Help!
Okay, I have a Listview (with items) and I want it so that everytime i push a command button (Next Record button) it will select the next item/record in my Listview, as well as if i click the second command button (Previous Record button) then it will select the record before the one you are currently on...pretty much in general a Next and Previous buttons instead of manualy clicking each record...How do I do this?...Please Help - All code is welcome
Thanks.
-
May 19th, 2010, 09:42 AM
#2
Re: Help!
Try this:
Code:
Private Sub Command1_Click() '~~~ Next button
If ListView1.ListItems.Count <= 0 Then Exit Sub
If ListView1.SelectedItem.Index = ListView1.ListItems.Count Then
ListView1.ListItems(1).Selected = True
Else
ListView1.ListItems(ListView1.SelectedItem.Index + 1).Selected = True
End If
End Sub
Private Sub Command2_Click() '~~~ Previous button
If ListView1.ListItems.Count <= 0 Then Exit Sub
If ListView1.SelectedItem.Index = 1 Then
ListView1.ListItems(ListView1.ListItems.Count).Selected = True
Else
ListView1.ListItems(ListView1.SelectedItem.Index - 1).Selected = True
End If
End Sub
Make sure to set the Hide Selection property of ListView to FALSE.
...
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
May 19th, 2010, 10:47 AM
#3
Re: Help!
Does your ListView only display one line at time?
-
May 19th, 2010, 09:14 PM
#4
Thread Starter
Addicted Member
Re: Help!
No, unfortunatly that code did not do anything, and what do you mean does it displayy one line at a time? its a listview with a whole lot of items/records.
-
May 19th, 2010, 09:22 PM
#5
Re: Help!
Code:
Private Sub cmdNext_Click()
If (ListView1.ListItems.Count > 0) And (ListView1.SelectedItem.Index < ListView1.ListItems.Count) Then
ListView1.ListItems.Item(ListView1.SelectedItem.Index + 1).Selected = True
End If
End Sub
Private Sub cmdPrev_Click()
If (ListView1.ListItems.Count > 0) And (ListView1.SelectedItem.Index > 1) Then
ListView1.ListItems.Item(ListView1.SelectedItem.Index - 1).Selected = True
End If
End Sub
Make sure HideSelection is not turned on in the ListView properties or you want see the selection marker.
-
May 20th, 2010, 03:23 AM
#6
Re: Help!
 Originally Posted by anthony_pacitto3
No, unfortunatly that code did not do anything, and what do you mean does it displayy one line at a time? its a listview with a whole lot of items/records.
Then, tell us more details. If possible, try to include snapshots of what you want, etc.
We don't know what you have in your mind..!
....
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
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
|