Results 1 to 9 of 9

Thread: Data comnbo auto drop down[RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Angry Data comnbo auto drop down[RESOLVED]

    I am using data combo in an application.
    We know that, when we press on the drop-down arrow, drop down list appears on it.

    What i want is that, when i enter the very first character in the data combo, its drop down list should automatically be shown.

    Plz guide.

    (if u don't understand what i am trying to say, plz let me know.)

    Thankx
    Last edited by engineer; Jun 3rd, 2005 at 11:19 AM.
    software engineer

  2. #2
    Fanatic Member joltremari's Avatar
    Join Date
    Sep 2000
    Location
    Mississippi
    Posts
    674

    Re: Data comnbo auto drop down

    I'm not sure if I understand what your trying to do, but, in the properties of your combobox change the "Style" property to 2 - Dropdown List and try that

    ciao
    JO
    "I have not failed. I've just found 10,000 ways that won't work."
    'Thomas Edison'

    "If we knew what it was we were doing it wouldn't be called research, would it?"
    'Albert Einstein'

    VB6

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Data comnbo auto drop down

    DataCombos don't work the same way, in this respect, as does a standard combo. To auto drop down a datacombo, use this
    VB Code:
    1. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    2. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    3. Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    4.  
    5. Private Const VK_LBUTTON = &H1
    6.  
    7. Private Type POINTAPI
    8.     X As Long
    9.     Y As Long
    10. End Type
    11.  
    12. Private Sub DropOnFocus(CB As DataCombo)
    13. Dim pt As POINTAPI
    14. Dim lHandle As Long
    15. Const HighBit = &H8000
    16. Call GetCursorPos(pt)
    17. lHandle = WindowFromPoint(pt.X, pt.Y)
    18. If (lHandle <> CB.hWnd) Or ((GetAsyncKeyState(VK_LBUTTON) And HighBit) = 0) Then
    19.     SendKeys "%{Down}"
    20. End If
    21. End Sub

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Re: Data comnbo auto drop down

    Dear it works....

    when i write a word, the matching word from the list appears in the data combo.

    But...

    I want that when i type the letter, the dopr down should get dropped(as i drops when we click on the rdop down arrow).
    software engineer

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Re: Data comnbo auto drop down

    Dear hack,

    My reply was for the guy who replied before u.
    I ma gona test ur adviced code

    software engineer

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Data comnbo auto drop down

    Did you put a call to the DropOnFocus sub in the GotFocus event of the datacombo?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Re: Data comnbo auto drop down

    Thankx Hack,

    It worked.

    Thankx again
    software engineer

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Data comnbo auto drop down[RESOLVED]

    In the event anyone reading this is interested, that code was for a DataCombo. The code to auto drop down a standard combo is much shorter.
    VB Code:
    1. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    2. (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    3. lParam As Long) As Long
    4.  
    5. Private Const CB_SHOWDROPDOWN = &H14F
    6.  
    7. Private Sub Combo1_GotFocus()  
    8.    Dim lngDropDown As Long
    9.    lngDropDown = SendMessage(Combo1.hwnd, CB_SHOWDROPDOWN, 1, ByVal 0&)
    10. End Sub

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Re: Data comnbo auto drop down[RESOLVED]

    Hack

    Thankx for this also.

    software engineer

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