Question to scroll a listbox

andrews

Well-known member
Joined
Nov 22, 2011
Messages
167
Programming Experience
5-10
Maybe simple question but I do not know the answer.
In my program is filling a listbox with words and I want to scroll the listbox because there are many words.
And then I have to put in a choosen word in a inputbox but I can not scroll the listbox because the inputbox is already waiting for a answer.
Solution?
Thanks for any response.
 
Hi,

If you are saying that your InputBox currently has the Focus when your Form loads then you can force your list box to get the focus using the Select method of the ListBox. You can then use the SelectedIndexChanged Event of the ListBox to populate the InputBox as you scroll through the ListBox.

Hope that helps.

Cheers,

Ian
 
Problem for the moment
I wrote:
Form1.ListBox2.Items.Clear()
For i = 1 To plaats
Form1.ListBox2.Items.Add(rijkand(i))
Next
Form1.ListBox2.Focus()
bestword = Form1.ListBox2.SelectedItem ' error : no conversion from object to string

What I want
- after filling the listbox I want to be able to choose (select) an item and gives this (string)value to a a variable
 
Last edited:
Sorry, Ianryder I had :
Private Sub ListBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
bestwoord = CType(ListBox2.SelectedItem, String)
End Sub
But nothing happens.
I do not know what the reason is.
 
No, bestwoord is a public variable.
the public subroutines are written in a module
after filling the listbox the program do not stops, I am not able to select an item
the same thing with a combobox?

Maybe I had to finish the routine after filling and then continue by clicking a button?
 
Last edited:
Back
Top