Results 1 to 6 of 6

Thread: scrolling a list box?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Posts
    91

    scrolling a list box?

    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!

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    This will scroll to the last item:
    VB Code:
    1. If ListBox1.Items.Count > 0 Then
    2.             ListBox1.SelectedIndex = ListBox1.Items.Count - 1
    3.         End If

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Posts
    91
    this causes an error. the exact coe i am using in this part is
    VB Code:
    1. Sub listwords()
    2.         Dim arrCommands() As String = {"look", "go", "get", "put", "inventory"}
    3.         Dim i As Single = 0
    4.         Me.lstText.Items.Add("")
    5.         Me.lstText.Items.Add("Commands Are:")
    6.         For i = 0 To 4
    7.             Me.lstText.Items.Add(arrCommands(i))
    8.         Next
    9.         If lstText.Items.Count > 0 Then
    10.             lstText.SelectedIndex = lstText.Items.Count - 1
    11.         End If
    12.     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"

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Like it says you can have an item selected when the selectionmode propert is set to None. Change it to something that allows selections.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Posts
    91
    wow... this is definately not the newb forum...

    i dont know vb that well, so i am asking for the code lolol

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width