/// <summary> /// Initializes a new instance of the Row class with an array of strings /// representing Cells and the foreground color, background color, and font /// of the Row /// </summary> /// <param name="items">An array of strings that represent the Cells of the Row</param> /// <param name="foreColor">The foreground Color of the Row</param> /// <param name="backColor">The background Color of the Row</param> /// <param name="font">The Font used to draw the text in the Row's Cells</param> public I3Row(string[] items, Color foreColor, Color backColor, Font font) { if (items == null) { throw new ArgumentNullException("items", "string[] cannot be null"); } this.Init(); this.ForeColor = foreColor; this.BackColor = backColor; this.Font = font; if (items.Length > 0) { I3Cell[] cells = new I3Cell[items.Length]; for (int i = 0; i < items.Length; i++) { cells[i] = new I3Cell(items[i]); } this.Cells.AddRange(cells); } }
/// <summary> /// Handler for the PropertyGrid's SelectedObjectsChanged event /// </summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">An EventArgs that contains the event data</param> protected void PropertyGrid_SelectedObjectsChanged(object sender, EventArgs e) { object[] objects = ((PropertyGrid)sender).SelectedObjects; this.previewColumnModel.Columns.Clear(); if (objects.Length == 1) { I3Column column = (I3Column)objects[0]; I3Cell cell = this.previewTableModel[0, 0]; SetCellData(cell, column); I3Column newColumn = (I3Column)Activator.CreateInstance(column.GetType()); PropertyInfo[] properties = column.GetType().GetProperties(); foreach (PropertyInfo property in properties) { if (property.GetGetMethod() != null && property.GetSetMethod() != null) { object value = property.GetValue(column, null); property.SetValue(newColumn, value, null); } } newColumn.Tag = column; newColumn.PropertyChanged += new I3ColumnEventHandler(newColumn_PropertyChanged); this.previewColumnModel.Columns.Add(newColumn); } this.previewTable.Invalidate(); }
/// <summary> /// Compares two objects and returns a value indicating whether one is less /// than, equal to or greater than the other /// </summary> /// <param name="a">First object to compare</param> /// <param name="b">Second object to compare</param> /// <returns>-1 if a is less than b, 1 if a is greater than b, or 0 if a equals b</returns> public override int Compare(object a, object b) { I3Cell cell1 = (I3Cell)a; I3Cell cell2 = (I3Cell)b; // check for null cells if (cell1 == null && cell2 == null) { return(0); } else if (cell1 == null) { return(-1); } else if (cell2 == null) { return(1); } // check for null data string text = cell1.Row.TableModel.Table.ColumnModel.Columns[cell1.Index].DataToString(cell1.Data); string text2 = cell2.Row.TableModel.Table.ColumnModel.Columns[cell2.Index].DataToString(cell2.Data); if (text == null && text2 == null) { return(0); } else if (text == null) { return(-1); } return(text.CompareTo(text2)); }
/// <summary> /// Gets the CheckBoxCellRenderer specific data used by the Renderer from /// the specified Cell /// </summary> /// <param name="cell">The Cell to get the CheckBoxCellRenderer data for</param> /// <returns>The CheckBoxCellRenderer data for the specified Cell</returns> protected I3CheckBoxRendererData GetCheckBoxRendererData(I3Cell cell) { object rendererData = this.GetRendererData(cell); if (rendererData == null || !(rendererData is I3CheckBoxRendererData)) { if (cell.CheckState == CheckState.Unchecked) { rendererData = new I3CheckBoxRendererData(I3CheckBoxStates.UncheckedNormal); } else if (cell.CheckState == CheckState.Indeterminate && cell.ThreeState) { rendererData = new I3CheckBoxRendererData(I3CheckBoxStates.MixedNormal); } else { rendererData = new I3CheckBoxRendererData(I3CheckBoxStates.CheckedNormal); } this.SetRendererData(cell, rendererData); } this.ValidateCheckState(cell, (I3CheckBoxRendererData)rendererData); return((I3CheckBoxRendererData)rendererData); }
/// <summary> /// Compares two objects and returns a value indicating whether one is less /// than, equal to or greater than the other /// </summary> /// <param name="a">First object to compare</param> /// <param name="b">Second object to compare</param> /// <returns>-1 if a is less than b, 1 if a is greater than b, or 0 if a equals b</returns> public override int Compare(object a, object b) { I3Cell cell1 = (I3Cell)a; I3Cell cell2 = (I3Cell)b; // check for null cells if (cell1 == null && cell2 == null) { return(0); } else if (cell1 == null) { return(-1); } else if (cell2 == null) { return(1); } // check for null data if (cell1.Data == null && cell2.Data == null) { return(0); } else if (cell1.Data == null) { return(-1); } else if (cell2.Data == null) { return(1); } return(Convert.ToDateTime(cell1.Data).CompareTo(Convert.ToDateTime(cell2.Data))); }
/// <summary> /// Compares two objects and returns a value indicating whether one is less /// than, equal to or greater than the other /// </summary> /// <param name="a">First object to compare</param> /// <param name="b">Second object to compare</param> /// <returns>-1 if a is less than b, 1 if a is greater than b, or 0 if a equals b</returns> public override int Compare(object a, object b) { I3Cell cell1 = (I3Cell)a; I3Cell cell2 = (I3Cell)b; // check for null cells if (cell1 == null && cell2 == null) { return(0); } else if (cell1 == null) { return(-1); } else if (cell2 == null) { return(1); } int retVal = 0; // check for null data if (cell1.Data == null && cell2.Data == null) { retVal = 0; } else if (cell1.Data == null) { retVal = -1; } else if (cell2.Data == null) { retVal = 1; } // since images aren't comparable, if retVal = 0 and the ImageColumn // they belong to allows text drawing, compare the text properties // to determine order if (retVal == 0 && ((I3ImageColumn)this.TableModel.Table.ColumnModel.Columns[this.SortColumn]).DrawText) { // check for null data string text = cell1.Row.TableModel.Table.ColumnModel.Columns[cell1.Index].DataToString(cell1.Data); string text2 = cell2.Row.TableModel.Table.ColumnModel.Columns[cell2.Index].DataToString(cell2.Data); if (text == null && text2 == null) { return(0); } else if (text == null) { return(-1); } retVal = text.CompareTo(text2); } return(retVal); }
/// <summary> /// Initializes a new instance of the CellKeyEventArgs class with /// the specified source Cell, table, row index, column index and /// cell bounds /// </summary> /// <param name="cell">The Cell that Raised the event</param> /// <param name="table">The Table the Cell belongs to</param> /// <param name="cellPos"></param> /// <param name="cellRect">The Cell's bounding rectangle</param> /// <param name="kea"></param> public I3CellKeyEventArgs(I3Cell cell, I3Table table, I3CellPos cellPos, Rectangle cellRect, KeyEventArgs kea) : base(kea.KeyData) { this.cell = cell; this.table = table; this.row = cellPos.Row; this.column = cellPos.Column; this.cellRect = cellRect; }
/// <summary> /// Initializes a new instance of the CellKeyEventArgs class with /// the specified source Cell, table, row index, column index, cell /// bounds and KeyEventArgs /// </summary> /// <param name="cell">The Cell that Raised the event</param> /// <param name="table">The Table the Cell belongs to</param> /// <param name="row">The Row index of the Cell</param> /// <param name="column">The Column index of the Cell</param> /// <param name="cellRect">The Cell's bounding rectangle</param> /// <param name="kea"></param> public I3CellKeyEventArgs(I3Cell cell, I3Table table, int row, int column, Rectangle cellRect, KeyEventArgs kea) : base(kea.KeyData) { this.cell = cell; this.table = table; this.row = row; this.column = column; this.cellRect = cellRect; }
/// <summary> /// Initializes a new instance of the CellEventArgs class with /// the specified Cell source, column index and row index /// </summary> /// <param name="source">The Cell that Raised the event</param> /// <param name="editor">The CellEditor used to edit the Cell</param> /// <param name="table">The Table that the Cell belongs to</param> /// <param name="row">The Column index of the Cell</param> /// <param name="column">The Row index of the Cell</param> /// <param name="cellRect"></param> public I3CellEditEventArgs(I3Cell source, II3CellEditor editor, I3Table table, int row, int column, Rectangle cellRect) : base(source, column, row) { this.editor = editor; this.table = table; this.cellRect = cellRect; this.cancel = false; }
/// <summary> /// Initializes a new instance of the CellMouseEventArgs class with /// the specified source Cell, table, row index, column index and /// cell bounds /// </summary> /// <param name="cell">The Cell that Raised the event</param> /// <param name="table">The Table the Cell belongs to</param> /// <param name="row">The Row index of the Cell</param> /// <param name="column">The Column index of the Cell</param> /// <param name="cellRect">The Cell's bounding rectangle</param> public I3CellMouseEventArgs(I3Cell cell, I3Table table, int row, int column, Rectangle cellRect) : base(MouseButtons.None, 0, -1, -1, 0) { this.cell = cell; this.table = table; this.row = row; this.column = column; this.cellRect = cellRect; }
/// <summary> /// Initializes a new instance of the RowEventArgs class with /// the specified Row source, row index, start index, end index /// and affected Cell /// </summary> /// <param name="source">The Row that originated the event</param> /// <param name="rowIndex">The index of the Row</param> /// <param name="cell">The affected Cell</param> /// <param name="cellFromIndex">The start index of the affected Cell(s)</param> /// <param name="cellToIndex">The end index of the affected Cell(s)</param> /// <param name="eventType">The type of event</param> public I3RowEventArgs(I3Row source, int rowIndex, I3Cell cell, int cellFromIndex, int cellToIndex, I3RowEventType eventType) : base() { this.source = source; this.rowIndex = rowIndex; this.cell = cell; this.cellFromIndex = cellFromIndex; this.cellToIndex = cellToIndex; this.eventType = eventType; }
/// <summary> /// Initializes a new instance of the CellMouseEventArgs class with /// the specified source Cell, table, row index, column index and /// cell bounds /// </summary> /// <param name="cell">The Cell that Raised the event</param> /// <param name="table">The Table the Cell belongs to</param> /// <param name="cellPos"></param> /// <param name="cellRect">The Cell's bounding rectangle</param> /// <param name="mea"></param> public I3CellMouseEventArgs(I3Cell cell, I3Table table, I3CellPos cellPos, Rectangle cellRect, MouseEventArgs mea) : base(mea.Button, mea.Clicks, mea.X, mea.Y, mea.Delta) { this.cell = cell; this.table = table; this.row = cellPos.Row; this.column = cellPos.Column; this.cellRect = cellRect; }
/// <summary> /// Initializes a new instance of the CellEditor class with default settings /// </summary> protected I3CellEditor() { this.control = null; this.cell = null; this.table = null; this.cellPos = I3CellPos.Empty; this.cellRect = Rectangle.Empty; this.mouseMessageFilter = new I3MouseMessageFilter(this); this.keyMessageFilter = new I3KeyMessageFilter(this); }
/// <summary> /// Creates a new instance of the specified collection item type /// </summary> /// <param name="itemType">The type of item to create</param> /// <returns>A new instance of the specified object</returns> protected override object CreateInstance(Type itemType) { I3Cell cell = (I3Cell)base.CreateInstance(itemType); // newly created items aren't added to the collection // until editing has finished. we'd like the newly // created cell to show up in the table immediately // so we'll add it to the CellCollection now this.cells.Add(cell); return(cell); }
/// <summary> /// 虚拟方法,从Table中移除编辑控件 /// Conceals the editor from the user and removes it from the Table's /// Control collection /// </summary> protected virtual void RemoveEditControl() { this.control.Visible = false; this.control.Parent = null; this.table.Focus(); this.cell = null; this.table = null; this.cellPos = I3CellPos.Empty; this.cellRect = Rectangle.Empty; }
private void CheckCells() { I3Row row = this.previewTableModel.Rows[0]; row.Cells.Clear(); for (int i = 0; i <= this.columns.Count - 1; i++) { I3Cell cell = new I3Cell(); SetCellData(cell, this.columns[i]); row.Cells.Add(cell); } }
/// <summary> /// Compares two objects and returns a value indicating whether one is less /// than, equal to or greater than the other /// </summary> /// <param name="a">First object to compare</param> /// <param name="b">Second object to compare</param> /// <returns>-1 if a is less than b, 1 if a is greater than b, or 0 if a equals b</returns> public override int Compare(object a, object b) { I3Cell cell1 = (I3Cell)a; I3Cell cell2 = (I3Cell)b; // check for null cells if (cell1 == null && cell2 == null) { return(0); } else if (cell1 == null) { return(-1); } else if (cell2 == null) { return(1); } int retVal = 0; if (cell1.Checked && !cell2.Checked) { retVal = -1; } else if (!cell1.Checked && cell2.Checked) { retVal = 1; } // if the cells have the same checked value and the CheckBoxColumn // they belong to allows text drawing, compare the text properties // to determine order if (retVal == 0 && ((I3CheckBoxColumn)this.TableModel.Table.ColumnModel.Columns[this.SortColumn]).DrawText) { // check for null data string text = cell1.Row.TableModel.Table.ColumnModel.Columns[cell1.Index].DataToString(cell1.Data); string text2 = cell2.Row.TableModel.Table.ColumnModel.Columns[cell2.Index].DataToString(cell2.Data); if (text == null && text2 == null) { return(0); } else if (text == null) { return(-1); } retVal = text.CompareTo(text2); } return(retVal); }
/// <summary> /// 准备编辑,继承父类的功能 /// Prepares the CellEditor to edit the specified Cell /// </summary> /// <param name="cell">The Cell to be edited</param> /// <param name="table">The Table that contains the Cell</param> /// <param name="cellPos">A CellPos representing the position of the Cell</param> /// <param name="cellRect">The Rectangle that represents the Cells location and size</param> /// <param name="userSetEditorValues">Specifies whether the ICellEditors /// starting value has already been set by the user</param> /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns> public override bool PrepareForEditing(I3Cell cell, I3Table table, I3CellPos cellPos, Rectangle cellRect, bool userSetEditorValues) { if (!(table.ColumnModel.Columns[cellPos.Column] is I3DropDownColumn)) { throw new InvalidOperationException("Cannot edit Cell as DropDownCellEditor can only be used with a DropDownColumn"); } I3DropDownColumn dropDownColumn = table.ColumnModel.Columns[cellPos.Column] as I3DropDownColumn; this.DropDownStyle = dropDownColumn.DropDownStyle; return(base.PrepareForEditing(cell, table, cellPos, cellRect, userSetEditorValues)); }
/// <summary> /// Destroys the specified instance of the object /// </summary> /// <param name="instance">The object to destroy</param> protected override void DestroyInstance(object instance) { if (instance != null && instance is I3Cell) { I3Cell cell = (I3Cell)instance; // the specified cell is about to be destroyed so // we need to remove it from the CellCollection first this.cells.Remove(cell); } base.DestroyInstance(instance); }
/// <summary> /// Gets the ButtonCellRenderer specific data used by the Renderer from /// the specified Cell /// </summary> /// <param name="cell">The Cell to get the ButtonCellRenderer data for</param> /// <returns>The ButtonCellRenderer data for the specified Cell</returns> protected I3ButtonRendererData GetButtonRendererData(I3Cell cell) { object rendererData = this.GetRendererData(cell); if (rendererData == null || !(rendererData is I3ButtonRendererData)) { rendererData = new I3ButtonRendererData(); this.SetRendererData(cell, rendererData); } return((I3ButtonRendererData)rendererData); }
/// <summary> /// Compares two objects and returns a value indicating whether one is less /// than, equal to or greater than the other /// </summary> /// <param name="a">First object to compare</param> /// <param name="b">Second object to compare</param> /// <returns>-1 if a is less than b, 1 if a is greater than b, or 0 if a equals b</returns> protected int Compare(I3Cell a, I3Cell b) { switch (this.SortOrder) { case SortOrder.None: return(0); case SortOrder.Descending: return(-this.Comparer.Compare(a, b)); default: return(this.Comparer.Compare(a, b)); } }
/// <summary> /// Initializes a new instance of the PaintCellEventArgs class with /// the specified graphics, table, row index, column index, selected value, /// focused value, mouse value and clipping rectangle /// </summary> /// <param name="g">The Graphics used to paint the Cell</param> /// <param name="cell">The Cell to be painted</param> /// <param name="table">The Table the Cell belongs to</param> /// <param name="row">The Row index of the Cell</param> /// <param name="column">The Column index of the Cell</param> /// <param name="selected">Specifies whether the Cell is selected</param> /// <param name="focused">Specifies whether the Cell has focus</param> /// <param name="sorted">Specifies whether the Cell's Column is sorted</param> /// <param name="editable">Specifies whether the Cell is able to be edited</param> /// <param name="enabled">Specifies whether the Cell is enabled</param> /// <param name="cellRect">The rectangle in which to paint the Cell</param> public I3PaintCellEventArgs(Graphics g, I3Cell cell, I3Table table, int row, int column, bool selected, bool focused, bool sorted, bool editable, bool enabled, Rectangle cellRect) : base(g, cellRect) { this.cell = cell; this.table = table; this.row = row; this.column = column; this.selected = selected; this.focused = focused; this.sorted = sorted; this.editable = editable; this.enabled = enabled; this.cellRect = cellRect; this.handled = false; }
private void SetCellData(I3Cell cell, I3Column column) { if (column is I3ButtonColumn) { cell.Data = null; cell.Data = "Button"; } else if (column is I3CheckBoxColumn) { cell.Data = null; cell.Data = "Checkbox"; cell.Checked = true; } else if (column is I3ColorColumn) { cell.Data = null; cell.Data = Color.Red; } else if (column is I3ComboBoxColumn) { cell.Data = null; cell.Data = "ComboBox"; } else if (column is I3DateTimeColumn) { cell.Data = null; cell.Data = DateTime.Now; } else if (column is I3ImageColumn) { cell.Data = null; cell.Data = "Image"; } else if (column is I3NumberColumn || column is I3ProgressBarColumn) { cell.Data = null; cell.Data = 50; } else if (column is I3TextColumn) { cell.Data = null; cell.Data = "Text"; } else { cell.Data = null; } }
/// <summary> /// Corrects any differences between the check state of the specified Cell /// and the check state in its rendererData /// </summary> /// <param name="cell">The Cell to chech</param> /// <param name="rendererData">The CheckBoxRendererData to check</param> private void ValidateCheckState(I3Cell cell, I3CheckBoxRendererData rendererData) { switch (cell.CheckState) { case CheckState.Checked: { if (rendererData.CheckState <= I3CheckBoxStates.UncheckedDisabled) { rendererData.CheckState |= (I3CheckBoxStates)4; } else if (rendererData.CheckState >= I3CheckBoxStates.MixedNormal) { rendererData.CheckState -= (I3CheckBoxStates)4; } break; } case CheckState.Indeterminate: { if (rendererData.CheckState <= I3CheckBoxStates.UncheckedDisabled) { rendererData.CheckState |= (I3CheckBoxStates)8; } else if (rendererData.CheckState <= I3CheckBoxStates.CheckedDisabled) { rendererData.CheckState |= (I3CheckBoxStates)4; } break; } default: { if (rendererData.CheckState >= I3CheckBoxStates.MixedNormal) { rendererData.CheckState -= (I3CheckBoxStates)8; } else if (rendererData.CheckState >= I3CheckBoxStates.CheckedNormal) { rendererData.CheckState -= (I3CheckBoxStates)4; } break; } } }
/// <summary> /// 刷新前缀选择数据 /// </summary> private void RefreshPrefix() { tableModel.Rows.Clear(); if (curItem != null) { foreach (string prefix in curItem.PrefixList) { I3Row row = tableModel.Rows.Add(); I3Cell selectCell = row.Cells.Add(); if (curItem.SelectedPrefixList.Contains(prefix)) { selectCell.Checked = true; } row.Cells.Add().Data = prefix; } } }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public void AddColumns(I3ColumnModel model) { this.model = model; //this.columnTable.HeaderRenderer = model.Table.HeaderRenderer; I3CellStyle cellStyle = new I3CellStyle(); cellStyle.Padding = new I3CellPadding(0, 0, 0, 0); this.columnTable.BeginUpdate(); for (int i = 0; i < model.Columns.Count; i++) { I3Row row = new I3Row(); I3Cell cell = new I3Cell("", model.Columns[i].Visible); cell.Tag = model.Columns[i].Width; cell.CellStyle = cellStyle; row.Cells.Add(cell); cell = new I3Cell(model.Columns[i].Caption); cell.Tag = model.Columns[i].Width; cell.CellStyle = cellStyle; row.Cells.Add(cell); this.columnTable.TableModel.Rows.Add(row); } this.columnTable.SelectionChanged += new IE310.Table.Events.I3SelectionEventHandler(columnTable_SelectionChanged); this.columnTable.CellCheckChanged += new IE310.Table.Events.I3CellCheckBoxEventHandler(columnTable_CellCheckChanged); if (this.columnTable.VScroll) { this.columnTable.ColumnModel.Columns[0].Width -= SystemInformation.VerticalScrollBarWidth; } if (this.columnTable.TableModel.Rows.Count > 0) { this.columnTable.TableModel.Selections.SelectCell(0, 0); } this.columnTable.EndUpdate(); }
/// <summary> /// 计算将Cell绘制完全时需要的大小 /// </summary> /// <param name="g"></param> /// <param name="cell"></param> /// <param name="text"></param> /// <param name="font"></param> /// <param name="sf"></param> public virtual void CalCellNeedSize(Graphics g, I3Cell cell, string text, Font font, StringFormat sf, int maxWidth, int addWidth, int addHeight) { if (maxWidth <= 0) { maxWidth = I3ColumnModel.MaxAutoColumnWidth_Const; } if (text != null && text.Length != 0) { SizeF sizeF = g.MeasureString(text, font, maxWidth, sf); cell.NeedWidth = sizeF.Width + cell.Padding.Left + cell.Padding.Right + addWidth; cell.NeedHeight = sizeF.Height + cell.Padding.Top + cell.Padding.Bottom + addHeight; } else { cell.NeedWidth = I3ColumnModel.MinColumnWidth_Const; cell.NeedHeight = I3TableModel.MinRowHeight_Const; } }
/// <summary> /// Prepares the CellEditor to edit the specified Cell /// </summary> /// <param name="cell">The Cell to be edited</param> /// <param name="table">The Table that contains the Cell</param> /// <param name="cellPos">A CellPos representing the position of the Cell</param> /// <param name="cellRect">The Rectangle that represents the Cells location and size</param> /// <param name="userSetEditorValues">Specifies whether the ICellEditors /// starting value has already been set by the user</param> /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns> public override bool PrepareForEditing(I3Cell cell, I3Table table, I3CellPos cellPos, Rectangle cellRect, bool userSetEditorValues) { // if (!(table.ColumnModel.Columns[cellPos.Column] is I3NumberColumn)) { throw new InvalidOperationException("Cannot edit Cell as NumberCellEditor can only be used with a NumberColumn"); } if (!(table.ColumnModel.GetCellRenderer(cellPos.Column) is I3NumberCellRenderer)) { throw new InvalidOperationException("Cannot edit Cell as NumberCellEditor can only be used with a NumberColumn that uses a NumberCellRenderer"); } this.NumberColumnType = ((I3NumberColumn)table.ColumnModel.Columns[cellPos.Column]).NumberColumnType; this.Minimum = Convert.ToDecimal(((I3NumberColumn)table.ColumnModel.Columns[cellPos.Column]).Minimum); this.Maximum = Convert.ToDecimal(((I3NumberColumn)table.ColumnModel.Columns[cellPos.Column]).Maximum); this.Increment = Convert.ToDecimal(((I3NumberColumn)table.ColumnModel.Columns[cellPos.Column]).Increment); return(base.PrepareForEditing(cell, table, cellPos, cellRect, userSetEditorValues)); }
/// <summary> /// Initializes a new instance of the Row class with an array of strings /// representing Cells /// </summary> /// <param name="items">An array of strings that represent the Cells of /// the Row</param> public I3Row(string[] items) { if (items == null) { throw new ArgumentNullException("items", "string[] cannot be null"); } this.Init(); if (items.Length > 0) { I3Cell[] cells = new I3Cell[items.Length]; for (int i = 0; i < items.Length; i++) { cells[i] = new I3Cell(items[i]); } this.Cells.AddRange(cells); } }
/// <summary> /// 虚拟方法,准备编辑,在ICellEditor中定义 /// Prepares the CellEditor to edit the specified Cell /// </summary> /// <param name="cell">The Cell to be edited</param> /// <param name="table">The Table that contains the Cell</param> /// <param name="cellPos">A CellPos representing the position of the Cell</param> /// <param name="cellRect">The Rectangle that represents the Cells location and size</param> /// <param name="userSetEditorValues">Specifies whether the ICellEditors /// starting value has already been set by the user</param> /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns> public virtual bool PrepareForEditing(I3Cell cell, I3Table table, I3CellPos cellPos, Rectangle cellRect, bool userSetEditorValues) { //初始化值 this.cell = cell; this.table = table; this.cellPos = cellPos; this.cellRect = cellRect; //检查用户是否已经自己设置了编辑控件的值,如果没有则调用 SetEditValue() 方法进行设置 // check if the user has already set the editors value for us if (!userSetEditorValues) { this.SetEditValue(); } //设置编辑控件的位置和大小 this.SetEditLocation(cellRect); //引发开始编辑事件 // raise the BeginEdit event I3CellEditEventArgs e = new I3CellEditEventArgs(cell, this, table, cellPos.Row, cellPos.Column, cellRect); e.Handled = userSetEditorValues; this.OnBeginEdit(e); //如果编辑被退出,移动编辑控件并返回false // if the edit has been canceled, remove the editor and return false if (e.Cancel) { this.RemoveEditControl(); return(false); } return(true); }