|
-
May 8th, 2007, 04:06 PM
#1
Thread Starter
Frenzied Member
[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:
''' <summary>
''' Determines whether this instance has changed.
''' </summary>
''' <returns>
''' <c>true</c> if this instance has changed; otherwise, <c>false</c>.
''' </returns>
Private Function hasChanged() As Boolean
Dim objCArHabLit As New CARHabLit
With objCArHabLit
.Id = Me.txtId.Text
.Designacao = Me.txtDesignacao.Text
End With
If objCArHabLit.CompareTo(_objCARHabLit) <> 0 Then
Return True
End If
Return False
End Function
comments please...
Last edited by zuperman; May 8th, 2007 at 04:15 PM.
-
May 8th, 2007, 04:28 PM
#2
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.
-
May 8th, 2007, 04:31 PM
#3
Thread Starter
Frenzied Member
Re: Detect changes
 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...
-
May 8th, 2007, 04:34 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|