void t1_TextChanged(object sender, TextChangedEventArgs e) { gridControl1.Model.Selections.Clear(); if (!string.IsNullOrEmpty(this.t1.Text) && this.t1.Text.IndexOf('(') > -1) { try { string formula = this.t1.Text.Substring(this.t1.Text.IndexOf("(")); string[] args = (formula.Substring(1, (this.t1.Text.EndsWith(")") ? formula.Length - 2 : formula.Length - 1)).Replace("(", string.Empty).Replace(")", string.Empty)).Split(new char[] { ',' }); foreach (string arg in args) { if (IsCellReference(arg)) { string[] cells = engine.GetCellsFromArgs(arg.Replace("\"", "")); int firstRow = engine.RowIndex(cells[0].ToString()); int lastRow = engine.RowIndex(cells[cells.Length - 1].ToString()); int firstCol = engine.ColIndex(cells[0].ToString()); int lastCol = engine.ColIndex(cells[cells.Length - 1].ToString()); gridControl1.Model.Selections.Add(GridRangeInfo.Cells(firstRow, firstCol, lastRow, lastCol)); } } gridControl1.InvalidateCells(); } catch (Exception) { // MessageBox.Show(ex.Message); } } }
void buttonEdit1_TextChanged(object sender, EventArgs e) { this.textBox1.Font = new Font("Segoe UI Semibold", 14.25f, FontStyle.Bold); SizeF sf = TextRenderer.MeasureText(this.textBox1.Text, this.textBox1.Font); if (textBox1.Width < sf.Width) { this.textBox1.Font = new Font("Segoe UI Semibold", 9f, FontStyle.Bold); } else { this.textBox1.Font = new Font("Segoe UI Semibold", 14.25f, FontStyle.Bold); } this.gridControl1.Selections.Clear(); if (!string.IsNullOrEmpty(this.textBox1.Text) && this.textBox1.Text.IndexOf('(') > -1) { try { string formula = this.textBox1.Text.Substring(this.textBox1.Text.IndexOf("(")); string[] args = (formula.Substring(1, (this.textBox1.Text.EndsWith(")") ? formula.Length - 2 : formula.Length - 1)).Replace("(", string.Empty).Replace(")", string.Empty)).Split(new char[] { ',' }); foreach (string arg in args) { if (IsCellReference(arg.Replace(" ", string.Empty))) { string[] cells = engine.GetCellsFromArgs(arg.Replace(" ", string.Empty).Replace("\"", "")); int firstRow = engine.RowIndex(cells[0].ToString()); int lastRow = engine.RowIndex(cells[cells.Length - 1].ToString()); int firstCol = engine.ColIndex(cells[0].ToString()); int lastCol = engine.ColIndex(cells[cells.Length - 1].ToString()); this.gridControl1.Selections.Add(GridRangeInfo.Cells(firstRow, firstCol, lastRow, lastCol)); } } } catch (Exception ex) { this.resultLable.Text = ex.Message; } } }