r/visualbasic • • Apr 26 '21

Visual Basic || Final Project Year

Good afternoon everyone, I’m in my last year of schooling and I have to develop a year-end project (PAP), in my PAP, I have a problem in my listview when I add some items, automatically appears the scrollbar when I run out of field of view, but does not automatically walk down when placing a new item.

5 Upvotes

16 comments sorted by

View all comments

1

u/RJPisscat Apr 26 '21

This will select then scroll into view.

MyListView.Items(myListView.Items.Count-1).Selected = True    ' optional
TMyListView.EnsureVisible(myListView.Items.Count-1)           ' required

1

u/realgonca Apr 27 '21

The code actually Works, the scroll actually goes to the bottom, when i click on any item that is in the listview, but i wanted me to add a new item the scroll went to the bottom. That is every new item that selects the scroll goes down to show the last item placed on the listview

1

u/Rikdol Apr 27 '21

Cant you do that in two parts?

Add the item Call the click event for the list

1

u/realgonca Apr 27 '21

I don’t know how you can help me

1

u/Rikdol Apr 27 '21 edited Apr 27 '21

i tried the following to create a list. after adding a new item use the second call: .topindex = .newindex

Dim i&

i& = 0

Do While i& <= 15

Form2.List1.AddItem "Item" & i&

Form2.List1.TopIndex = Form2.List1.NewIndex

i& = i& + 1

Loop

I just realised this is for .net Visual Basic and not VB6 :) , maybe it will still be helpful for you...

1

u/realgonca Apr 27 '21

I’ll try when I’m on the computer thanks

1

u/realgonca Apr 27 '21

u/Rikdol Thanks for your help, but I tried the Rjpisscat code first and it really worked. I appreciate your time trying to help