/// <summary> /// Initializes a new instance of the ColumnCollectionEditor class /// using the specified collection type /// </summary> /// <param name="type">The type of the collection for this editor to edit</param> public I3ColumnCollectionEditor(Type type) : base(type) { this.columns = null; this.previewColumnModel = new I3ColumnModel(); this.previewColumnModel.Columns.Add(new I3TextColumn("Column", 116)); this.previewTableModel = new I3TableModel(); this.previewTableModel.Rows.Add(new I3Row()); //I3Cell cell = new I3Cell(); //cell.Editable = false; //cell.ToolTipText = "This is a Cell ToolTip"; //this.previewTableModel.Rows[0].Cells.Add(cell); this.previewTableModel.DefaultRowHeight = 20; this.previewTable = new I3Table(); this.previewTable.EnableColumnHeaderContextMenu = false; this.previewTable.Preview = true; this.previewTable.Size = new Size(120, 274); this.previewTable.Location = new Point(0, 24); this.previewTable.GridLines = I3GridLines.Both; this.previewTable.TabStop = false; this.previewTable.EnableToolTips = true; this.previewTable.ColumnModel = this.previewColumnModel; this.previewTable.TableModel = this.previewTableModel; this.previewLabel = new Label(); this.previewLabel.Name = "previewLabel"; this.previewLabel.Text = "нц└└:"; this.previewLabel.Size = new Size(140, 16); this.previewLabel.Location = new Point(0, 8); }
/// <summary> /// Edits the value of the specified object using the specified /// service provider and context /// </summary> /// <param name="context">An ITypeDescriptorContext that can be /// used to gain additional context information</param> /// <param name="isp">A service provider object through which /// editing services can be obtained</param> /// <param name="value">The object to edit the value of</param> /// <returns>The new value of the object. If the value of the /// object has not changed, this should return the same object /// it was passed</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider isp, object value) { this.columns = (I3ColumnCollection)value; // for some reason (might be beacause Column is an // abstract class) the table doesn't get redrawn // when a columns property changes, but we can get // around that by subscribing to the columns // PropertyChange event and passing the message on // to the table ourselves. we need to do this for // all the existing columns in the collection for (int i = 0; i < this.columns.Count; i++) { this.columns[i].PropertyChanged += new I3ColumnEventHandler(column_PropertyChanged); } I3ColumnModel model = (I3ColumnModel)context.Instance; I3Table oldTable = model.Table; if (oldTable != null) { oldTable.ColumnModel = null; } this.previewTable.ColumnModel = model; this.CheckCells(); object returnObject = base.EditValue(context, isp, value); if (oldTable != null) { oldTable.ColumnModel = model; } this.previewTable.ColumnModel = null; if (model.Table != null) { model.Table.PerformLayout(); model.Table.Refresh(); } return(returnObject); }