Results 1 to 2 of 2

Thread: Dropdownlists (Comboboxes)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    89

    Dropdownlists (Comboboxes)

    Hi, I'm currently converting a vb 6 app to asp.net using VB.net. This let's the user type a letter and the combobox will open up and go to the item: like if the list had 3 items:

    Black
    White
    Green

    Typing "G" will move the highlighter to Green. Anybody have ideas for the equivalent of the following code?



    VB Code:
    1. Private Sub cboGlasses_KeyPress(ByVal KeyAscii As Integer)
    2.         Dim chrKey As String
    3.         Dim i As Long
    4.  
    5.         chrKey = Chr(KeyAscii)
    6.  
    7.         If cboGlasses.Items. = "" Then
    8.             For i = 0 To cboGlasses.ListCount - 1
    9.                 If UCase(Left(cboGlasses.List(i), 1)) = UCase(chrKey) Then
    10.                     KeyAscii = 0
    11.                     cboGlasses.Text = cboGlasses.List(i)
    12.                     Exit For
    13.                 End If
    14.             Next
    15.         End If
    16.  
    17.     End Sub


    Chris

  2. #2
    Addicted Member
    Join Date
    Aug 1999
    Posts
    164
    Add a combobox to your form. Additems of Blue, Green, Red, etc. Then set the DropDownStyle to "DropDown". The standard combobox control does this automatically. I believe the old Vb6 comboboxes did this also.
    -Shurijo

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