public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { edSvc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService; CheckedListBox listBox = new CheckedListBox(); listBox.BorderStyle = BorderStyle.None; listBox.CheckOnClick = true; List <string> checkeditems = value as List <string>; DBComboListBoxField control = context.Instance as DBComboListBoxField; ContextObject contextObject = control.GetRoot(); if (contextObject is Project) { Project project = contextObject as Project; TableInfo entityInfo; entityInfo = project.Database.Tables.Find(e => e.Name == control.LookupTable); if (entityInfo == null) { return(null); } foreach (ColumnInfo column in entityInfo.Columns) { if (checkeditems.Contains(column.Name)) { listBox.Items.Add(column.Name, true); continue; } listBox.Items.Add(column.Name); } } //foreach (string v in caption as List<string>) //{ // listBox.Items[.Add(v,true); //} this.edSvc.DropDownControl(listBox); List <string> items = new List <string>(); foreach (object item in listBox.CheckedItems) { items.Add(item.ToString()); } return(items); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { edSvc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService; ListBox listBox = new ListBox(); listBox.BorderStyle = BorderStyle.None; listBox.SelectedValueChanged += new EventHandler(this.TextChanged); string keyfield = value as string; DBComboListBoxField control = context.Instance as DBComboListBoxField; if (control == null) { return(null); } ContextObject contextObject = control.GetRoot(); if (contextObject is Project) { Project project = contextObject as Project; TableInfo entityInfo; entityInfo = project.Database.Tables.Find(e => e.Name == control.LookupTable); if (entityInfo == null) { return(null); } foreach (ColumnInfo column in entityInfo.Columns) { if (keyfield == column.Name) { int index = listBox.Items.Add(column.Name); listBox.SelectedIndex = index; continue; } listBox.Items.Add(column.Name); } } this.edSvc.DropDownControl(listBox); return((listBox.SelectedItem == null) ? string.Empty : listBox.SelectedItem.ToString()); }