Detecting if a checkbox has been modfied help?

R

Rob W

Greetings again,

I have a form where data is loaded into textboxes, datepicker and a
checkbox.

The textbox modified property if data is loaded into the textbox will be set
to true, so I could simply reset it to false and then every time a change is
made, track it.

I was looking at a similar mechanism for the checkbox, as I want to build up
an SQL string to ONLY update fields if the data has been changed on the
form.

I was wondering is there such a property for the checkbox?

I did think about checking its value as integer when first loaded and then
when they press the save button, compare values.
Or perhaps use the CheckChanged event and use boolean variables to detect
changes.

Does anyone have any other solutions, ideally better than mine ;-)

Thanks
Rob
 
F

Family Tree Mike

Rob said:
Greetings again,

I have a form where data is loaded into textboxes, datepicker and a
checkbox.

The textbox modified property if data is loaded into the textbox will be set
to true, so I could simply reset it to false and then every time a change is
made, track it.

I was looking at a similar mechanism for the checkbox, as I want to build up
an SQL string to ONLY update fields if the data has been changed on the
form.

I was wondering is there such a property for the checkbox?

I did think about checking its value as integer when first loaded and then
when they press the save button, compare values.
Or perhaps use the CheckChanged event and use boolean variables to detect
changes.

Does anyone have any other solutions, ideally better than mine ;-)

Thanks
Rob

The CheckChanged event is the proper one for your question.

I believe that you are describing changing a database on any form
change. If this is correct then, I would handle all the pertinent
events in one routine as follows, adding all the control events of course:

Private Sub UpdateHandler _
(ByVal sender As Object, ByVal e As EventArgs) _
Handles DateTimePicker1.ValueChanged, _
CheckBox1.CheckedChanged, _
TextBox1.Validated

MessageBox.Show("Do an update")
' put real code here.
End Sub

I don't think you want to handle the textbox.TextChanged event, as that
would cause a database update as each character is changed. You could
set the tag attribute of the controls to indicate which field is
involved in generating your query. This will possibly help code the sql
statement as you only need to update the one field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top