The binding object has a Parse event that is raised when a new value is added to the component to go to the object. It's a middle-tier between the component and the class object.
One useful thing is it can parse an ID and save it's Name.
To test, create textbox and add a binding object to this textbox. Add a parse event to the binding object and in the event add the code below.
void b_Parse(object sender, ConvertEventArgs e)
{
int i = -1;
int.TryParse(e.Value.ToString(), out i);
int id;
string name="";
if(i>=0)
{
foreach(object o in bs.List)
{
id = (o as Product).Id;
if(i==id)
{
name = (o as Product).Name;
e.Value = name;
break;
}
}
}
}
The important part is the LOOP that through all bindingsource and if find the ID in the list will change the display data to an other data.
Sunday, May 6, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment