Results 1 to 5 of 5

Thread: Combo Selection

  1. #1

    Thread Starter
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718

    Combo Selection

    How do you make the combo box select the nearest match when you type in the search field (automatically select it) when you resize it so that it's all visible?
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    dont get it ... could you elaborate a bit please ?
    -= a peet post =-

  3. #3
    Hyperactive Member sw_is_great's Avatar
    Join Date
    Nov 2003
    Posts
    330
    Can you please explain a bit more .
    Regards

  4. #4

    Thread Starter
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    OK, get a combo box, and populate it with a few number for example 0011,0013,0016 ok, now drag the bottom border down so that it reveals the list under it (looks like a textbox and a listbox put together) and start typing 0016. As you will see, it doesn't highlight the closest match to what you have in the text field. Is there a way to make it select the first object and keep selecting the closest match until it gets the correct one? the best it can do is scroll the box but that's useless if the item is towards the bottom.
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

  5. #5
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 2001
    Location
    New Delhi , INDIA
    Posts
    858

    Lightbulb

    use api function sendmessage .


    declare section....


    Private Const CB_FINDSTRING As Long = &H14C
    Private Const CB_FINDSTRINGEXACT As Long = &H158

    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
    ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) _
    As Long


    in the keypress event of combobox :


    indx = SendMessage(combo1.hwnd, CB_FINDSTRING, -1, _
    ByVal SearchKey)


    indx will give u the listindex of the nearest search .
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

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