Detect when user modifies a value in a bound textbox

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
 
J

James Minns

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
 
M

Miha Markic [MVP C#]

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
 
J

James Minns

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
 

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