A common binding of ComboBox is to bind a dataset to it. But if you bind an ilist to it, you have a skill.
If your ilist is list <idictionary>, it won't work. The displaymember and valuemember of ComboBox need to get the value from the object's property, while the idictionary is only the key, so it won't work. If you want to bind ilist or arraylist, you have to use an entity class (concept in Java or ORM) as the object for storing data, and then add the object to the list, then you can assign a value to datasource. Defines a class and has two attributes.
Public class valueobject {
Private string _ name;
Private string _ value;
Internal name
{
Get {return _ value ;}
Set {_ value = value ;}
}
}
Then, use
Arraylist list = new arraylist ();
For (INT I = 0; I <3; I ++)
{
Valueobject Vo = new valueobject ();
VO. Name = "";
VO. value = "1 ";
List. Add (VO );
}
ComboBox CBB = new ComboBox ();
CBB. datasource = List;
CBB. displaymember = "name ";
CBB. valuemember = "value ";
In this way, the value of CBB. selectedvalue is obtained.
If Java is used, the role of VO will be clear.
In addition, many people do not know how to select a list based on the read value.
ComboBox. selectedvalue = "XXX" can be selected.
The following is a stupid method. I found that ienumerator enumer = org_type_id.items.getenumerator () was used before this method ();
Int I = 0;
Enumer. Reset ();
While (enumer. movenext ())
{
Datarowview dt = (datarowview) enumer. Current;
If (dt ["org_type_id"]. tostring (). Equals (DRV ["org_type_id"]. tostring ()))
{
Org_type_id.selectedindex = I;
}
I ++;
}