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

2

u/Chriand VB.Net Intermediate Apr 26 '21

Does it work similar to listboxes?

Listview.selectedindex = listview.items.count or something like this

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/RJPisscat Apr 27 '21

I cannot follow you at all.

I thought you were asking that an added ListViewItem be scrolled into view immediately after it's added. Now I don't know what you're on about.

Perhaps you can mock up some screen shots of how it looks now and then use your favorite painting app to mock up how you want it to look instead.

1

u/realgonca Apr 27 '21

I’ll do it when I have it on the computer thanks

1

u/RJPisscat Apr 27 '21

I just watched the video. I have answered a question for you earlier about how to update a line when a quantity is added.

In the video I see you add an item, then move the scrollbar manually. You want it to move automatically. The code I gave you does that.

Listview1.AddItem(LI)
Listview1.EnsureVisible(ListView1.Items.Count-1)

----

Acabei de ver o video. Eu respondi uma pergunta para você anteriormente sobre como atualizar uma linha quando uma quantidade é atualizada.

No vídeo, vejo que você adiciona um item e move a barra de rolagem manualmente. Você quer que ele se mova automaticamente. O código que eu dei a você faz isso.

Voce esta em portugal ou no brasil? Falo espanhol mas consigo ler português.

1

u/realgonca Apr 27 '21

-

I can’t believe it really worked, thank you so much for your help in my problems

1

u/realgonca Apr 27 '21

Sou português, ainda bem porque assim posso te pedir ajuda.
Muito obrigado mesmo estás sempre aqui a ajudar

1

u/RJPisscat Apr 27 '21

De nada 😊

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