Key code:
Public static void Bind <T> (this RepositoryItemComboBox combox, ICollection source) {/* Note: * FieldName is set for the involved columns; otherwise, the node cannot be selected. * eg: * List <PersonInfo> _ source = new List <PersonInfo> (); * _ source. add (new PersonInfo ("Sven", "Petersen"); * _ source. add (new PersonInfo ("Cheryl", "Saylor"); * _ source. add (new PersonInfo ("Dirk", "Luchte"); * repositoryItemComboBox1.Bind <PersonInfo> (_ source); */if (source! = Null) {try {combox. beginUpdate (); combox. items. addRange (source); combox. parseEditValue + = combox_ParseEditValue;} finally {combox. endUpdate () ;}}// solve the problem that the 'object must be iconvertid' private static void combox_ParseEditValue (object sender, ConvertEditValueEventArgs e) {e. value = e. value. toString (); e. handled = true;} code usage:
string[] test = new string[3] { "aa", "bb", "cc" }; repositoryItemComboBox1.Bind<PersonInfo>(test);
Code effect:
. Csharpcode ,. csharpcode pre {font-size: small; color: black; font-family: Las LAS, "Courier New", courier, monospace; background-color: # ffffff; /* white-space: pre ;*/}. csharpcode pre {margin: 0em ;}. csharpcode. rem {color: #008000 ;}. csharpcode. kwrd {color: # 0000ff ;}. csharpcode. str {color: #006080 ;}. csharpcode. op {color: # effecc0 ;}. csharpcode. preproc {color: # cc6633 ;}. csharpcode. asp {background-color: # ffff00 ;}. csharpcode. html {color: #800000 ;}. csharpcode. attr {color: # ff0000 ;}. csharpcode. alt {background-color: # f4f4f4; width: 100%; margin: 0em ;}. csharpcode. lnum {color: #606060 ;}