PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Detect when user modifies a value in a bound textbox

Reply

Detect when user modifies a value in a bound textbox

 
Thread Tools Rate Thread
Old 20-06-2006, 09:37 AM   #1
James Minns
Guest
 
Posts: n/a
Default Detect when user modifies a value in a bound textbox


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


  Reply With Quote
Old 20-06-2006, 09:54 AM   #2
Miha Markic [MVP C#]
Guest
 
Posts: n/a
Default Re: Detect when user modifies a value in a bound textbox

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" <minns@DELETEME.inwind.it> wrote in message
news:ea2gQTElGHA.4508@TK2MSFTNGP05.phx.gbl...
> 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
>



  Reply With Quote
Old 20-06-2006, 10:44 AM   #3
James Minns
Guest
 
Posts: n/a
Default Re: Detect when user modifies a value in a bound textbox

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 [MVP C#]" <miha at rthand com> wrote in message
news:%23qu2xcElGHA.2304@TK2MSFTNGP02.phx.gbl...
> 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" <minns@DELETEME.inwind.it> wrote in message
> news:ea2gQTElGHA.4508@TK2MSFTNGP05.phx.gbl...
>> 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
>>

>
>



  Reply With Quote
Old 20-06-2006, 11:14 AM   #4
Miha Markic [MVP C#]
Guest
 
Posts: n/a
Default Re: Detect when user modifies a value in a bound textbox

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" <minns@DELETEME.inwind.it> wrote in message
news:eqllp4ElGHA.3816@TK2MSFTNGP02.phx.gbl...
>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 [MVP C#]" <miha at rthand com> wrote in message
> news:%23qu2xcElGHA.2304@TK2MSFTNGP02.phx.gbl...
>> 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" <minns@DELETEME.inwind.it> wrote in message
>> news:ea2gQTElGHA.4508@TK2MSFTNGP05.phx.gbl...
>>> 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
>>>

>>
>>

>
>



  Reply With Quote
Old 21-06-2006, 11:51 PM   #5
James Minns
Guest
 
Posts: n/a
Default Re: Detect when user modifies a value in a bound textbox

Perfect - problem solved!
Thank you very much.

James

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:eolUnJFlGHA.1264@TK2MSFTNGP05.phx.gbl...
> 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" <minns@DELETEME.inwind.it> wrote in message
> news:eqllp4ElGHA.3816@TK2MSFTNGP02.phx.gbl...
>>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 [MVP C#]" <miha at rthand com> wrote in message
>> news:%23qu2xcElGHA.2304@TK2MSFTNGP02.phx.gbl...
>>> 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" <minns@DELETEME.inwind.it> wrote in message
>>> news:ea2gQTElGHA.4508@TK2MSFTNGP05.phx.gbl...
>>>> 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



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off