Alain,
I would add a handler for each controls "Changed" event to a single event
Handler that set a Dirty field.
Something like
Public Class MainForm
Private WithEvents TextBox1 As TextBox
Private WithEvents TextBox2 As TextBox
Private WithEvents ComboBox1 As ComboBox
Private WithEvents ListBox1 As ListBox
Private m_dirty As Boolean
Private Sub Form_Changed(ByVal sender As Object, _
ByVal e As EventArgs) _
Handles TextBox1.TextChanged, TextBox2.TextChanged, _
ComboBox1.SelectedValueChanged, ComboBox1.TextChanged _
ListBox1.SelectValueChanged
m_dirty = True
End Sub
Private Sub TextBox1_Changed(ByVal sender As Object, _
ByVal e As EventArgs) Handles TextBox1.TextChanged
End Sub
End Class
Remember that a single event handler can handle multiple events, plus a
single event can be handled by multiple handlers.
An alternative method to the above is to set the Dirty flag in each of the
individual handlers for each control individually.
Hope this helps
Jay
Jay, what is the order of the event handlers? Will the TextBox1_Changed
occur first? Or will the Form_Changed occur first? Correct me if I'm
wrong, but if you use AddHandler to wire up the events, the order the
handlers are called will be the order in which they were wired up (FIFO).
Is that correct? But what is the order when using the handles clause?
My follow up question is: If the value in the text box after any text is
typed is the same as the previous value, it may not be necessary to mark
the form as "Dirty". How can you cancel or prevent the Form_Changed
handler from being called? Or is it even possible?
--
Chris
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.