T
Tim Jarvis
Hi,
I have an object that I am binding to a text box, this object exposes a
boolean field, and I have implemented a format event handler and a
parse event handler for the binding object, where I convert the bool
value to some meaningful text.
i.e.
Binding b = new
Binding("Text",AppOptions.Instance,"RemoteDataRetrieved");
b.Format += new ConvertEventHandler(RemoteDataRetrievedToString);
b.Parse += new ConvertEventHandler(StringToRemoteDataRetrieved);
textBox1.DataBindings.Add(b);
private void RemoteDataRetrievedToString(object sender,
ConvertEventArgs e)
{
if (e.DesiredType != typeof(string) ) return;
if (e.Value.GetType() != typeof(bool) ) return;
e.Value = (bool) e.Value ? "Remote Data Loaded" : "Remote Data is
not Loaded";
}
private void StringToRemoteDataRetrieved(object sender,
ConvertEventArgs e)
{
if (e.DesiredType != typeof(bool) ) return;
if (e.Value.GetType() != typeof(string) ) return;
e.Value = (string) e.Value == "Remote Data Loaded";
}
(sorry if the formatting is bizarre, my newsreader is wrapping Weirdly)
This actually seems to work ok, except when I change my business
object's property in code, the textbox does not update. I must be
missing something obvious.
Regards Tim.
I have an object that I am binding to a text box, this object exposes a
boolean field, and I have implemented a format event handler and a
parse event handler for the binding object, where I convert the bool
value to some meaningful text.
i.e.
Binding b = new
Binding("Text",AppOptions.Instance,"RemoteDataRetrieved");
b.Format += new ConvertEventHandler(RemoteDataRetrievedToString);
b.Parse += new ConvertEventHandler(StringToRemoteDataRetrieved);
textBox1.DataBindings.Add(b);
private void RemoteDataRetrievedToString(object sender,
ConvertEventArgs e)
{
if (e.DesiredType != typeof(string) ) return;
if (e.Value.GetType() != typeof(bool) ) return;
e.Value = (bool) e.Value ? "Remote Data Loaded" : "Remote Data is
not Loaded";
}
private void StringToRemoteDataRetrieved(object sender,
ConvertEventArgs e)
{
if (e.DesiredType != typeof(bool) ) return;
if (e.Value.GetType() != typeof(string) ) return;
e.Value = (string) e.Value == "Remote Data Loaded";
}
(sorry if the formatting is bizarre, my newsreader is wrapping Weirdly)
This actually seems to work ok, except when I change my business
object's property in code, the textbox does not update. I must be
missing something obvious.
Regards Tim.