listview and datagrid

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
8 posts Page 1 of 1
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

listview and datagrid
Dummy1912
Hello,

does anyone knowns how to get the last 3 records from a listview and a datagrid.

i want to get the second and the third column
to show in a label.
and the records don't need to select first

just read it when i load it.

anyone?
Code: Select all
                    If i Mod 2 = 0 Then
                        Label27.Text = lstView.Items(i).SubItems(2).Text
                        Label4.Text = lstView.Items(i).SubItems(2).Text
                        Label31.Text = lstView.Items(i).SubItems(2).Text
                    End If

this code just take the last row but this duplicate the record
not show the last 3 :(
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: listview and datagrid
Dummy1912
:( nobody?
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: listview and datagrid
MrAksel
To get the second and third column you can use this
Code: Select all
                    If i Mod 2 = 0 Then
                        Label27.Text = lstView.Items(i).SubItems(0).Text & " " & lstView.Items(i).SubItems(1).Text
                        Label4.Text = lstView.Items(i).SubItems(0).Text & " " & lstView.Items(i).SubItems(1).Text
                        Label31.Text = lstView.Items(i).SubItems(0).Text & " " & lstView.Items(i).SubItems(1).Text
                    End If
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: listview and datagrid
Dummy1912
sorry m8
but this don't change anything
i still get the same record 3x :(
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: listview and datagrid
MrAksel
What do you mean? The code you gave is designed to put the same record into three different labels :?
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: listview and datagrid
Dummy1912
well i need the last 3 records from the column 2 and 3
and show it in those labels.

like i said i got only the last record with my code
but i get 3x the same record.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: listview and datagrid
M1z23R
Code: Select all
Label27.Text = lstView.Items(lstView.Items.count-3).SubItems(2).Text
Label4.Text = lstView.Items(lstView.Items.count-2).SubItems(2).Text
Label31.Text = lstView.Items(lstView.Items.count-1).SubItems(2).Text
Maybe get like that ?
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: listview and datagrid
Dummy1912
hello m1z
i have checked it again and it works.
thanks m8 +rep for you :lol:
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
8 posts Page 1 of 1
Return to “Coding Help & Support”