Results 1 to 4 of 4

Thread: [RESOLVED] Detect changes

  1. #1

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Resolved [RESOLVED] Detect changes

    How do you manage to detect changes in a details form, so when the user press the cancel button you ask him if he wants to save changes?

    this is what im doing:

    vb Code:
    1. ''' <summary>
    2.     ''' Determines whether this instance has changed.
    3.     ''' </summary>
    4.     ''' <returns>
    5.     ''' <c>true</c> if this instance has changed; otherwise, <c>false</c>.
    6.     ''' </returns>
    7.     Private Function hasChanged() As Boolean
    8.         Dim objCArHabLit As New CARHabLit
    9.         With objCArHabLit
    10.             .Id = Me.txtId.Text
    11.             .Designacao = Me.txtDesignacao.Text
    12.         End With
    13.         If objCArHabLit.CompareTo(_objCARHabLit) <> 0 Then
    14.             Return True
    15.         End If
    16.         Return False
    17.     End Function

    comments please...
    Last edited by zuperman; May 8th, 2007 at 04:15 PM.

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: Detect changes

    If its a TextBox then set a flag in the text changed event;
    Code:
        Dim SomethingHasChanged As Boolean = False
        Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) _
        Handles TextBox1.TextChanged
            SomethingHasChanged = True
        End Sub
    The principle is the same for Radiobuttons and Checkboxes.

  3. #3

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: Detect changes

    Quote Originally Posted by Bulldog
    If its a TextBox then set a flag in the text changed event;
    Code:
        Dim SomethingHasChanged As Boolean = False
        Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) _
        Handles TextBox1.TextChanged
            SomethingHasChanged = True
        End Sub
    The principle is the same for Radiobuttons and Checkboxes.
    thsta not an option when you have a lot of controls... im searching the board and found this:
    http://www.vbforums.com/showpost.php...11&postcount=6

    seems cool...

  4. #4
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: Detect changes

    Yes, if you have a lot of controls then that post shows a good solution.

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