override public object EditValue(ITypeDescriptorContext ctx, IServiceProvider provider, object value) { Index idx = ctx.Instance as Index; Trigger trig = ctx.Instance as Trigger; ViewTableBase parent = null; if (idx != null) { parent = idx.Table; } else if (trig != null) { parent = trig.ViewTableBase; } // initialize editor service _edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (_edSvc == null) { return(value); } if (value == null) { value = String.Empty; } if (String.IsNullOrEmpty(value.ToString()) == true) { value = String.Empty; } string[] values = value.ToString().Split(','); // populate the list _list.Items.Clear(); if (parent is Table) { foreach (Column c in ((Table)parent).Columns) { CheckState check = CheckState.Unchecked; for (int n = 0; n < values.Length; n++) { if (values[n].Trim() == String.Format("[{0}]", c.ColumnName)) { check = CheckState.Checked; break; } } _list.Items.Add(c.ColumnName, check); } } else { try { using (DbCommand cmd = trig.GetConnection().CreateCommand()) { cmd.CommandText = ((View)parent).SqlText; using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly)) using (DataTable tbl = reader.GetSchemaTable()) { foreach (DataRow row in tbl.Rows) { CheckState check = CheckState.Unchecked; for (int n = 0; n < values.Length; n++) { if (values[n].Trim() == String.Format("[{0}]", row[SchemaTableColumn.ColumnName])) { check = CheckState.Checked; break; } } _list.Items.Add(row[SchemaTableColumn.ColumnName].ToString(), check); } } } } catch { } } _list.Height = Math.Min(300, (_list.Items.Count + 1) * _list.Font.Height); // show the list _cancel = false; _edSvc.DropDownControl(_list); // build return value from checked items on the list if (!_cancel) { // build a comma-delimited string with the checked items StringBuilder sb = new StringBuilder(); foreach (object item in _list.CheckedItems) { if (sb.Length > 0) { sb.Append(", "); } sb.AppendFormat("[{0}]", item.ToString()); } return(sb.ToString()); } // done return(value); }