I am trying to scroll down a listbox, i.e., when they click list, it lists all of the items in a list. I can list and add to the listbox just fine, but when it reaches the end, it doesnt automatically scroll down... i need it 2 scroll down!
Printable View
I am trying to scroll down a listbox, i.e., when they click list, it lists all of the items in a list. I can list and add to the listbox just fine, but when it reaches the end, it doesnt automatically scroll down... i need it 2 scroll down!
This will scroll to the last item:
VB Code:
If ListBox1.Items.Count > 0 Then ListBox1.SelectedIndex = ListBox1.Items.Count - 1 End If
this causes an error. the exact coe i am using in this part isVB Code:
Sub listwords() Dim arrCommands() As String = {"look", "go", "get", "put", "inventory"} Dim i As Single = 0 Me.lstText.Items.Add("") Me.lstText.Items.Add("Commands Are:") For i = 0 To 4 Me.lstText.Items.Add(arrCommands(i)) Next If lstText.Items.Count > 0 Then lstText.SelectedIndex = lstText.Items.Count - 1 End If End Sub
the error states: "An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Cannot call this method when SelectionMode is SelectionMode.NONE"
Like it says you can have an item selected when the selectionmode propert is set to None. Change it to something that allows selections.
wow... this is definately not the newb forum...
i dont know vb that well, so i am asking for the code lolol
You don't need any code for that. Just select the Listbox on the form at designtime. Go to Properties on the lower right and find the SelectionMode property. Then set it to anything but None.