dotnetmonitor.com |
|
||||||||||||
| ComboBox binding does not directly support data
source property concatenation however you can use the ComboBox Format event to
concatenate multiple data source properties.
Sample: Concatenating data source properties using the Format event (VS 2005) (VS Project: ComboBoxBinding) /* Need to add a using statement for System.Globalization */ /* Bind a ComboBox (culturesCB) to a current framework cultures */ this.culturesCB.ValueMember = "LCID"; this.culturesCB.DataSource = CultureInfo.GetCultures(CultureTypes.FrameworkCultures);
/* Set the currently selected item in the ComboBox */ this.culturesCB.SelectedValue = CultureInfo.CurrentCulture.LCID;
/* Concatenate the IetfLanguageTag and DisplayName properties */ this.culturesCB.Format += delegate(object cb, ListControlConvertEventArgs args) { CultureInfo ci = (args.ListItem as CultureInfo);
if (null != ci) { args.Value = string.Format("{0}: {1}", ci.IetfLanguageTag, ci.DisplayName); } }; |
||||||||||||
|
||||||||||||