Detect when user modifies a value in a bound textbox

  • Thread starter Thread starter James Minns
  • Start date Start date
J

James Minns

Hi,
I have a form which views exactly one record from a dataset. It uses a
BindingSource and has bindings linking several textboxes to the data.

I would like to enable / disable the "Close" "OK" and "Cancel" buttons on
the form according to the row status; What is the best way to do this? I
can't find an event which fires when the user modifies a value in a bound
text box - I don't want to add a handler for every "TextChanged" event!

Thanks for any ideas,
James
 
I did try that; the event fires four times during the initialization of the
form when I press the OK button, but never when a bound text box is
modified.

This works if I call it every second, but I need an event:

Dim drView As DataRowView = MyBindingSource.Current
If drView.Row.HasVersion(DataRowVersion.Proposed) Then
UserHasModifiedSomething = True
James



Miha Markic said:
Hi James,

Did you try using BindingSource.CurrentItemChanged event?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

James Minns said:
Hi,
I have a form which views exactly one record from a dataset. It uses a
BindingSource and has bindings linking several textboxes to the data.

I would like to enable / disable the "Close" "OK" and "Cancel" buttons on
the form according to the row status; What is the best way to do this? I
can't find an event which fires when the user modifies a value in a bound
text box - I don't want to add a handler for every "TextChanged" event!

Thanks for any ideas,
James
 
You might implement DataTable.ColumnChanged event then.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

James Minns said:
I did try that; the event fires four times during the initialization of the
form when I press the OK button, but never when a bound text box is
modified.

This works if I call it every second, but I need an event:

Dim drView As DataRowView = MyBindingSource.Current
If drView.Row.HasVersion(DataRowVersion.Proposed) Then
UserHasModifiedSomething = True
James



Miha Markic said:
Hi James,

Did you try using BindingSource.CurrentItemChanged event?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

James Minns said:
Hi,
I have a form which views exactly one record from a dataset. It uses a
BindingSource and has bindings linking several textboxes to the data.

I would like to enable / disable the "Close" "OK" and "Cancel" buttons
on the form according to the row status; What is the best way to do
this? I can't find an event which fires when the user modifies a value
in a bound text box - I don't want to add a handler for every
"TextChanged" event!

Thanks for any ideas,
James
 
Perfect - problem solved!
Thank you very much.

James

Miha Markic said:
You might implement DataTable.ColumnChanged event then.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

James Minns said:
I did try that; the event fires four times during the initialization of
the form when I press the OK button, but never when a bound text box is
modified.

This works if I call it every second, but I need an event:

Dim drView As DataRowView = MyBindingSource.Current
If drView.Row.HasVersion(DataRowVersion.Proposed) Then
UserHasModifiedSomething = True
James



Miha Markic said:
Hi James,

Did you try using BindingSource.CurrentItemChanged event?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Hi,
I have a form which views exactly one record from a dataset. It uses a
BindingSource and has bindings linking several textboxes to the data.

I would like to enable / disable the "Close" "OK" and "Cancel" buttons
on the form according to the row status; What is the best way to do
this? I can't find an event which fires when the user modifies a value
in a bound text box - I don't want to add a handler for every
"TextChanged" event!

Thanks for any ideas,
James
 
Back
Top