A
Al Smith
Hi,
Last Nov, Neil Allen gave the response I have copied below that forces a control to update itself. The control updates itself in response to an event that I raise. I have built a test program and this works great and what is exactly what I was looking for. What is not so great, is that I cannot find documentation on this within MSDN. I would venture to say that I am either looking in the wrong place or I am looking at it and do not recognize.
If you are familiar with this and know of a MSDN link or other where I can learn more about "DataBindings" as demonstrated here, please provide.
Thanks very much.
Al
---------------------------------------------
In order to get the data binding "infrastructure" to recognise the
change in value of your form's property (MyValue) as soon as possible
you can implement a "changed event"...
public event EventHandler MyValueChanged;
.... note that the name should be the name of your property plus the
word "Changed".
Then in your property's set accessor you check for subscribers and
"raise the event"...
public string MyValue
{
get
{
return myValue;
}
set
{
myValue = value;
if (MyValueChanged != null)
{
MyValueChanged(this,System.EventArgs.Empty);
}
}
}
// Private field for property...
string myValue = "Default value";
You'll find that the data binding "infrastructure" has subscribed to
your event will update any properties "bound" to your form's MyValue
property.
Hope this helps
Regards
Neil Allen
Last Nov, Neil Allen gave the response I have copied below that forces a control to update itself. The control updates itself in response to an event that I raise. I have built a test program and this works great and what is exactly what I was looking for. What is not so great, is that I cannot find documentation on this within MSDN. I would venture to say that I am either looking in the wrong place or I am looking at it and do not recognize.
If you are familiar with this and know of a MSDN link or other where I can learn more about "DataBindings" as demonstrated here, please provide.
Thanks very much.
Al
---------------------------------------------
In order to get the data binding "infrastructure" to recognise the
change in value of your form's property (MyValue) as soon as possible
you can implement a "changed event"...
public event EventHandler MyValueChanged;
.... note that the name should be the name of your property plus the
word "Changed".
Then in your property's set accessor you check for subscribers and
"raise the event"...
public string MyValue
{
get
{
return myValue;
}
set
{
myValue = value;
if (MyValueChanged != null)
{
MyValueChanged(this,System.EventArgs.Empty);
}
}
}
// Private field for property...
string myValue = "Default value";
You'll find that the data binding "infrastructure" has subscribed to
your event will update any properties "bound" to your form's MyValue
property.
Hope this helps
Regards
Neil Allen