Groups | Blog | Home
all groups > dotnet windows forms databinding > september 2004 >

dotnet windows forms databinding : Forcing changes to a bound source during edits


Steve McLellan
9/24/2004 3:17:38 AM
Hi,

Given a textbox bound to a datasource, is there a way of pushing the value
from the textbox on, say, a KeyPress event? There doesn't seem to be much
documentation for data binding in general, and I'm sure I'm missing
something simple.

I've tried using EndCurrentEdit, but there's something weird going on
whereby the relevant ValueChanged event isn't firing properly - (sorry, code
is C++)

__property void set_MyValue( String __gc* myValue );
__event System::EventHandler *MyValueChanged;
virtual void OnMyValueChanged()
{
if ( MyValueChanged != NULL )
{
MyValueChanged( this, EventArgs::Empty ); // Normally,
this causes stuff to change. When I explicitly call EndCurrentEdit, it
doesn't.
}
}

Thanks in advance - this is driving me mad (and it's 3am)

Steve

Piotrek
9/25/2004 12:33:25 PM
Hi Steve

I suppose the only way to do that is to make your won custom control that
inherits from textbox. Then you have to manually fire the appropriate event
on KeyPress to make the binding belive that changes in your control have
been accepted

This is just a supposition...

Steve McLellan
9/27/2004 1:40:03 PM
[quoted text, click to view]

Hi,

Thanks for the reply. I've worked around the problem - there appears to be
some kind of abnormality in the databinding scheme (or maybe I'm using it
wrong). With the code I originally posted, binding to a String * caused it
to fail; binding to an int made it work. Weird, but I don't particularly
have the time or inclination to sort it out. Thanks again,

Steve

AddThis Social Bookmark Button