void Button_Click(object sender, EventArgs e) { ToolStripButton Button = sender as ToolStripButton; if (FpSpread.EditingControl is GeneralEditor) { GeneralEditor generaleditor = FpSpread.EditingControl as GeneralEditor; generaleditor.SelectedText = generaleditor.SelectedText + Button.Text; } else if (FpSpread.EditingControl is FarPoint.Win.Spread.CellType.RichTextEditor) { FarPoint.Win.Spread.CellType.RichTextEditor richTextEditor = FpSpread.EditingControl as FarPoint.Win.Spread.CellType.RichTextEditor; richTextEditor.SelectedText = richTextEditor.SelectedText + Button.Text; } FpSpread.StartCellEditing(null, false); }
void EditElement(object value, int RowIndex, int ColumnIndex) { GridElement Element = value as GridElement; if (Element != null) { if (Element.Value is DataColumn) { DataColumnEditor dataColumnEditor = new DataColumnEditor(Report, ActiveElement, Element); if (DialogResult.OK == dataColumnEditor.ShowDialog()) { ActiveSheet.Cells[ActiveElement].HorizontalAlignment = CellHorizontalAlignment.Center; ActiveSheet.Cells[ActiveElement].VerticalAlignment = CellVerticalAlignment.Center; ActiveSheet.Cells[ActiveElement].Value = dataColumnEditor.ReportElement; Cell Cell = ActiveSheet.Cells[ActiveElement]; Update(Cell.Row.Index, Cell.Column.Index); } } else if (Element.Value is Picture) { ImageEditor imageEditor = new ImageEditor(Report, ActiveElement, Element); if (DialogResult.OK == imageEditor.ShowDialog()) { ActiveSheet.Cells[ActiveElement].HorizontalAlignment = CellHorizontalAlignment.Center; ActiveSheet.Cells[ActiveElement].VerticalAlignment = CellVerticalAlignment.Center; ActiveSheet.Cells[ActiveElement].Value = imageEditor.ReportElement; Cell Cell = ActiveSheet.Cells[ActiveElement]; Update(Cell.Row.Index, Cell.Column.Index); } } else if (Element.Value is Slash) { SlashEditor slashEditor = new SlashEditor(Report, ActiveElement, Element); if (DialogResult.OK == slashEditor.ShowDialog()) { ActiveSheet.Cells[ActiveElement].HorizontalAlignment = CellHorizontalAlignment.Center; ActiveSheet.Cells[ActiveElement].VerticalAlignment = CellVerticalAlignment.Center; ActiveSheet.Cells[ActiveElement].Value = slashEditor.ReportElement; Cell Cell = ActiveSheet.Cells[ActiveElement]; Update(Cell.Row.Index, Cell.Column.Index); } } else if (Element.Value is Formula) { FormulaEditorUI FormulaEditorUI = new FormulaEditorUI(ActiveSheet); FormulaEditorUI.ShowInTaskbar = false; Formula Formula = Element.Value as Formula; FormulaEditorUI.SetFormula(Formula.Expression); if (DialogResult.OK == FormulaEditorUI.ShowDialog()) { Formula.Expression = FormulaEditorUI.GetFormula(); ActiveSheet.Cells[ActiveElement].Formula = FormulaEditorUI.GetFormula(); ActiveSheet.Cells[ActiveElement].HorizontalAlignment = CellHorizontalAlignment.Center; ActiveSheet.Cells[ActiveElement].VerticalAlignment = CellVerticalAlignment.Center; ActiveSheet.Cells[ActiveElement].Value = Element; Cell Cell = ActiveSheet.Cells[ActiveElement]; Update(Cell.Row.Index, Cell.Column.Index); } } else if (Element.Value is LiteralText) { Cell Cell = ActiveSheet.Cells[ActiveElement]; if (!(Cell.CellType is TextCellType)) { Cell.CellType = new TextCellType(); } EventArgs eventArgs = new EventArgs(); FpSpread.StartCellEditing(eventArgs, false); } else if (Element.Value is Variable) { VariableEditor VariableEditor = new VariableEditor(Report.Configuration.ReportParameters, Element); if (DialogResult.OK == VariableEditor.ShowDialog()) { ActiveSheet.Cells[ActiveElement].HorizontalAlignment = CellHorizontalAlignment.Center; ActiveSheet.Cells[ActiveElement].VerticalAlignment = CellVerticalAlignment.Center; ActiveSheet.Cells[ActiveElement].Value = VariableEditor.ReportElement; Cell Cell = ActiveSheet.Cells[ActiveElement]; Update(Cell.Row.Index, Cell.Column.Index); } } else if (Element.Value is ChartPainter) { ChartEditor ChartEditor = new ChartEditor(); ChartEditor.ChartPainter = Element.Value as ChartPainter; if (DialogResult.OK == ChartEditor.ShowDialog()) { Element.Value = ChartEditor.ChartPainter; Cell Cell = ActiveSheet.Cells[ActiveElement]; Update(Cell.Row.Index, Cell.Column.Index); } } } else { Cell Cell = ActiveSheet.Cells[ActiveElement]; if (!(Cell.CellType is TextCellType)) { Cell.CellType = new TextCellType(); } EventArgs eventArgs = new EventArgs(); FpSpread.StartCellEditing(eventArgs, false); } }