Results 1 to 4 of 4

Thread: Combobox change events [Resolved]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Combobox change events [Resolved]

    I have two comboboxes that are populated from a table (projects), in one case, and just adding items in another (months). The user can navigate through existing records and just view the data. Or, if they want, they can change the data, i.e. select a different project or month and save the changes. That works fine.
    But say the user makes a change, forgets to save it, and clicks the button to move to the next or previous record. I want to prompt them to save the change, if they want.
    The problem is that each time they advance or go back through the records, even if only viewing, the prompt comes up. I checked for a change in data in SelectedIndexChanged, but that fires when the record changes. Then I tried Click, but apparently that fires as well whenever the record changes.
    Is there a way to only trap a change when the user actually changes it, not automatic events? Thanks.
    Last edited by salvelinus; Jan 7th, 2004 at 11:40 AM.

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Are the controls data bound?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    No, all done in code.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Solved the question this way:
    VB Code:
    1. Private Sub cboProject_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles cboProject.MouseDown, _
    2.                                                                                                                      cboMonth.MouseDown
    3.         mblnMouseDown = True
    4.     End Sub
    5.  
    6.     Private Sub cboProject_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles cboProject.MouseUp, _
    7.                                                                                                                    cboMonth.MouseUp
    8.         If mblnMouseDown Then
    9.             mblnDataChanged = True
    10.             mblnMouseDown = False
    11.         End If
    12.     End Sub
    The Click event wasn't firing, I'd forgotten to take the flag out of SelectedIndexChanged. The Click event fires when the user clicks on the down arrow, though, not a selection, so it didn't work either.

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