Results 1 to 18 of 18

Thread: ComboBox not triggering Combo_Change Event? (Resolved)

  1. #1

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Resolved ComboBox not triggering Combo_Change Event? (Resolved)

    Ok, lets say I have a ComboBox with an item "hello" and the Text of the ComboBox is "hell"... When I click on the Button to drop down the list the Text automatically changes from "hell" to "hello" but the change event is NOT triggered..,

    Try it:


    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Combo1_Change()
    4.  Debug.Print "Text in Combo1_Change = """ & Combo1.Text & """"
    5. End Sub
    6.  
    7. Private Sub Combo1_Click()
    8.  Debug.Print "Text in Combo1_Click = """ & Combo1.Text & """"
    9. End Sub
    10.  
    11. Private Sub Combo1_DropDown()
    12.  Debug.Print "Text in Combo1_DropDown = """ & Combo1.Text & """"
    13. End Sub
    14.  
    15. Private Sub Combo1_GotFocus()
    16.  Debug.Print "Text in Combo1_GotFocus = """ & Combo1.Text & """"
    17. End Sub
    18.  
    19. Private Sub Combo1_Scroll()
    20.  Debug.Print "Text in Combo1_Scroll = """ & Combo1.Text & """"
    21. End Sub
    22.  
    23. Private Sub Combo1_Validate(Cancel As Boolean)
    24.  Debug.Print "Text in Combo1_Validate = """ & Combo1.Text & """"
    25. End Sub
    26.  
    27. Private Sub Form_Load()
    28.  With Combo1
    29.   .AddItem "hello"
    30.   .Text = "hell"
    31.  End With
    32. End Sub

    How can I know when the user clicks on the DropDown and changes the Text of the ComboBox?

    Thanks in advance!
    Last edited by Tec-Nico; Oct 3rd, 2004 at 01:49 PM.
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  2. #2
    Lively Member
    Join Date
    Jun 2004
    Location
    USA - Michigan
    Posts
    94
    How can u know when the user chmages the text in the cmbo

    wht i do is
    Code:
    If cmboName = "Stuff" Then
    Stuff to do
    End If
    Something along those lines work well for me
    --Semper Fi--

    --Area 61 Admin--

  3. #3

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    Have you tried the example I posted? The problem here is that it won't trigger any event to know when the Text is not what it used to be...

    Maybe I am not understanding you properly.. Could you post an example?
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    could you post some of your code? I have used a combo box a few times, but don't have a clear idea of what you want/need.

  5. #5
    Lively Member
    Join Date
    Jun 2004
    Location
    USA - Michigan
    Posts
    94
    Wht i am saying is use IF statements, from wht i think you want its the best

    ie

    If cmboName = "Hello" Then
    <Do w/e you want it to do>
    Else
    <Do wht u want>
    End If
    --Semper Fi--

    --Area 61 Admin--

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    From Help.

    ComboBox — changes the text in the text box portion of the control. Occurs only if the Style property is set to 0 (Dropdown Combo) or 1 (Simple Combo) and the user changes the text or you change the Text property setting through code.

  7. #7

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    That's the code... What you have to do is to click the button to Drop Down the list and then Click it again.

    Let me show what I am trying to get here:

    Attached Images Attached Images  
    Last edited by Tec-Nico; Aug 15th, 2004 at 02:13 AM.
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  8. #8

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    As you can see in the picture I posted before, when you click on the button to drop down the list the Text changes to "hello"

    Now look at Immediate, the Text shown there is "hell"

    In this next picture you will see the Change was never triggered. To get to this step click once again on the button to bring up the list:

    Attached Images Attached Images  
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  9. #9

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    Now, on the other hand, the Change is triggered when you select an item by clicking it.

    Let me show that in the final picture:

    Attached Images Attached Images  
    Last edited by Tec-Nico; Aug 15th, 2004 at 02:27 AM.
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  10. #10

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    With this in mind.. I would like to do either one of these two things:
    [list=a][*]Not allow the combo to change from "hell" to "hello" when dropping down[*]Know when the Combo changed its Text (So I can replace it for the other one)[/list=a]

    I hope this can be done...
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  11. #11

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    Anyone?
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  12. #12

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    Ok, I searched for some API's and this is what I got... If you have the same problem, try it.
    Attached Files Attached Files
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  13. #13

  14. #14

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    I am forced to do it since nobody took time to read the thread again..

    I just wanted to post the answer if someone had the same problem... I am sorry if I did something wrong.
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  15. #15
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    as long as you don't *ARGUE* with youreself...

  16. #16
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Originally posted by Tec-Nico
    I am forced to do it since nobody took time to read the thread again..

    I just wanted to post the answer if someone had the same problem... I am sorry if I did something wrong.
    No, nothing wrong. I didn't realize you were posting the answer.

  17. #17

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    Just one more thing... If you have the Combo inside a container you need to change this line of code:

    VB Code:
    1. OldWindowProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf NewWindowProc)

    For the Line:

    VB Code:
    1. OldWindowProc = SetWindowLong([B]ControlContainer[/B].hWnd, GWL_WNDPROC, AddressOf NewWindowProc)

    Where ControlContainer can be a picturebox, a frame, etc. So if you have the Combo1 inside of Picture1 the code would be:

    VB Code:
    1. OldWindowProc = SetWindowLong([B]Picture1[/B].hWnd, GWL_WNDPROC, AddressOf NewWindowProc)

    I tried to make this general by using Combo1.Parent.hWnd but for some reason it doesn't work.

    Oh, and one more thing... I wasn't talking to myself, I was just explaining what I got to the people who might find the thread and have the same problem.
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  18. #18
    Addicted Member AmmerBow's Avatar
    Join Date
    Sep 2000
    Posts
    195
    This works fine



    VB Code:
    1. Dim ComboRec As Integer
    2.  
    3. Private Sub Form_Load()
    4. ComboRec = cmbDNS.ListIndex
    5. End Sub
    6.  
    7. Private Sub combo1_Click()
    8. If ComboRec <> cmbDNS.ListIndex Then
    9. Debug.Print "check"
    10. ComboRec = cmbDNS.ListIndex
    11. End If
    12. End Sub
    Amiga 500 was here.

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