vb.net - Validate if any changes were made in TabPage -
so i'm wondering if can give me idea how something. have tabcontrol in application - load page - tabpage1 - 25-30 fields. on loading data - run loop save each control value .tag. have function called isdirty() checks each control's ctr.tag.tostring <> ctr.text. i'm having hard time figuring out how build quick handler check controls on form. tried using tagpage1.validating, doesn't anything.
my isdirty() function looks this...
private function isdirty() boolean isdirty = false each ctr control in tabpage1.controls if typeof ctr textbox , ctr.enabled = true if ctr.tag.tostring <> ctr.text isdirty = true end if end if 'more if statements comboboxes , such next end function
i'm hoping able plug function in somewhere , call on
if isdirty() msgbox "you have made change form" end if
do have call on each control's selection changed?
there 2 approaches
- when of controls not have change event handler, approach seems correct. way, in above code missed
exit for
, afterisdirty = true
. - when of controls have changed event handler implemented(this case if in design have data models/objects), rather checking changes in loop, prefer check when change made. mean declare form level variable
bool changed
. controlstextbox
,combobox
,radiobutton
,checkbox
, etc.. have change event handlers, if change made setchanged
true
.
Comments
Post a Comment