using a 'dirty flag'

  • Thread starter Thread starter AussieRules
  • Start date Start date
A

AussieRules

Hi,

I have heaps(50+) of text boxs on a form.

I want to have an dirtyflag type property that is set when any one of the 50
text boxes is change, so that i can prompt the user to save changes should
they exit.

Is there a easy way to do this against all 50 in one go, rather than have an
event to set the dirty flag against each text box ?

Thanks
 
Hi,

I have heaps(50+) of text boxs on a form.

I want to have an dirtyflag type property that is set when any one of the 50
text boxes is change, so that i can prompt the user to save changes should
they exit.

Is there a easy way to do this against all 50 in one go, rather than have an
event to set the dirty flag against each text box ?

Thanks

Set all of them to be handled by the same event...

Private Sub Changed(ByVal sender As Object, ByVal e As EventArgs) Handles _
TextBox1.TextChanged, _
TextBox2.TextChanged, _
TextBox3.TextChanged, _ ...

dirty = True
End Sub

Of course, you can also do it dynamically using AddHandler and
RemoveHandler...
 
Create an event handler which handles all the changed events for all boxes.
This can set a class level object to define which ones are dirty.

PS: Aussie does not rule, we won the cup cobber, and dont u forget it !

OHM
 
* "AussieRules said:
I have heaps(50+) of text boxs on a form.

I want to have an dirtyflag type property that is set when any one of the 50
text boxes is change, so that i can prompt the user to save changes should
they exit.

Is there a easy way to do this against all 50 in one go, rather than have an
event to set the dirty flag against each text box ?

Set the 'CausesValidation' property of the controls and add a common
'Validating' event handler to the controls by using 'AddHandler' (see
MSDN).
 
Back
Top