Results 1 to 5 of 5

Thread: [resolved] Combobox Autofind

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Albany, NY
    Posts
    489

    Resolved [resolved] Combobox Autofind

    We have severe issues with the combobox control in .Net 2003 at work. Basically when you type in something in the combobox it will look like the combobox finds the matching item, but it doesn't. I'm trying to write some AutoFind code to fix this.

    VB Code:
    1. Private Sub cmb_KeyUp _
    2.    ( _
    3.    ByVal sender As Object, _
    4.    ByVal e As System.Windows.Forms.KeyEventArgs _
    5.    ) Handles cmb.KeyUp
    6.  
    7.    Call Me.SelectComboboxItem(sender)
    8.    e.Handled = True
    9.  
    10. End Sub
    11.  
    12. Private Sub SelectComboboxItem(ByVal p_cmb As ComboBox)
    13.  
    14.    Dim retVal As Integer
    15.    Dim txtLen As Integer
    16.  
    17.    txtLen = p_cmb.Text.Length
    18.    p_cmb.Tag = p_cmb.Text
    19.    retVal = p_cmb.FindString(p_cmb.Text)
    20.  
    21.    If retVal <> -1 Then
    22.       p_cmb.SelectedIndex = retVal
    23.       'code below is ignored, entire text is selected
    24.       p_cmb.SelectionStart = txtLen
    25.       p_cmb.SelectionLength = p_cmb.Text.Length - txtLen
    26.    End If
    27.  
    28. End Sub

    Everything works except the SelectionStart and SelectLength parts. The properties change but when the code actually runs the entire text is selected instead of just selecting the letters that were filled in for the user. Anyone have any ideas on how to make this functionality work?
    Last edited by jcfowl; May 11th, 2005 at 11:19 AM. Reason: resolved

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