private Bitmap CreateFieldBitmap(GridControlBase grid, int rowIndex, int colIndex) { string fieldName = Grid[rowIndex]; GridStyleInfo style = new GridStyleInfo(); style.CellIdentity = new GridStyleInfoIdentity(grid.Model[rowIndex, colIndex].CellIdentity.Data, new GridCellPos(rowIndex, colIndex), true); style.CellType = GridCellTypeName.Header; style.HorizontalAlignment = GridHorizontalAlignment.Center; style.VerticalAlignment = GridVerticalAlignment.Middle; style.WrapText = false; style.Trimming = StringTrimming.EllipsisCharacter; style.Text = fieldName; Graphics g = null; Size size = new Size(120, 22); Rectangle bounds = new Rectangle(Point.Empty, size); GridCellRendererBase headerCellRenderer = grid.CellRenderers[GridCellTypeName.Header]; Bitmap bm = new Bitmap(Math.Max(1, size.Width), Math.Max(1, size.Height)); try { g = Graphics.FromImage(bm); BrushPaint.FillRectangle(g, bounds, style.Interior); headerCellRenderer.Draw(g, bounds, rowIndex, colIndex, style); } finally { if (g != null) { g.Dispose(); } } return(bm); }
string GetInfo(string name) { GridControl grid = this._splitter.ActivePane as GridControl; string s = ""; if (grid != null) { if (grid.CurrentCell.HasCurrentCell) { GridCurrentCell cc = grid.CurrentCell; GridCellRendererBase renderer = cc.Renderer; GridStyleInfo style = grid[cc.RowIndex, cc.ColIndex]; string ct = ""; if (renderer.HasControlText) { ct = " ControlText: " + renderer.ControlText; } string cv = ""; if (renderer.HasControlValue) { if (renderer.ControlValue != null) { ct = " ControlValue: " + renderer.ControlValue.ToString(); } else { ct = " ControlValue: null"; } } string st = style.Text; string sv = ""; if (style.CellValue != null) { sv = style.CellValue.ToString(); } s = string.Format("{0}{1} {2}\"{3}\", \"{4}\", StyleText: \"{5}\", StyleValue: \"{6}\" ", cc.IsModified ? "*" : "", name, grid.CurrentCell.RangeInfo, ct, cv, st, sv ); } else { s = name; } } return(s); }
bool IsOverCheckBox(int r, int c, MouseEventArgs e) { GridStyleInfo style = grid.Model[r, c]; GridCellRendererBase renderer = grid.CellRenderers[style.CellType]; renderer.PerformLayout(r, c, style, grid.RangeInfoToRectangle(GridRangeInfo.Cell(r, c))); if (renderer.RaiseHitTest(r, c, e, null) == GridHitTestContext.CheckBoxChecker) { return(true); } return(false); }
//FindAll - Loops through the cells in the grid and highlights all the values //that match with the given search string. private void btnFindAll_Click(object sender, EventArgs e) { if (cmbSearch.Text != null) { AddToSearchedList(cmbSearch.Text); SetOptions(); locInfo = GridRangeInfo.Table(); GridRangeInfo selRange = GridRangeInfo.Empty; int rowIndex, colIndex; if ((options & GridFindTextOptions.SelectionOnly) != GridFindTextOptions.None) { selRange = gridControl1.Selections.Ranges.ActiveRange; } else if ((options & GridFindTextOptions.ColumnOnly) != GridFindTextOptions.None) { selRange = GridRangeInfo.Col(gridControl1.CurrentCell.ColIndex); } else if ((options & GridFindTextOptions.WholeTable) != GridFindTextOptions.None) { selRange = GridRangeInfo.Cells(1, 1, gridControl1.RowCount, gridControl1.ColCount); } clearHighlight(); int startTop = selRange.Top; int startLeft = selRange.Left; do { GridStyleInfo style = gridControl1[startTop, startLeft]; GridCellRendererBase renderer = gridControl1.CellRenderers[style.CellType]; if (renderer.FindText(cmbSearch.Text, startTop, startLeft, options, true)) { gridControl1.CurrentCell.GetCurrentCell(out rowIndex, out colIndex); gridControl1[rowIndex, colIndex].BackColor = Color.Orange; } } while (GridFindReplaceDialogSink.GetNextCell(selRange, ref startTop, ref startLeft, false, chkSearchUp.Checked)); } this.highlighttext.HighlightText = ""; this.gridControl1.Refresh(); this.checkBox1.CheckState = CheckState.Unchecked; }
private void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e) { GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex]; GridTableCellStyleInfoIdentity id = style.TableCellIdentity; if (id.TableCellType == GridTableCellType.ColumnHeaderCell ) { // Workaround - gridGroupingControl1_TableControlCellButtonClicked does not get hit so // we'll check for the area where the button is and set e.Inner.Cancel = true GridCellRendererBase r = e.TableControl.CellRenderers[style.CellType]; r.PerformLayout(e.Inner.RowIndex, e.Inner.ColIndex, style, e.TableControl.RangeInfoToRectangle(GridRangeInfo.Cell(e.Inner.RowIndex, e.Inner.ColIndex))); if (r.RaiseHitTest(e.Inner.RowIndex, e.Inner.ColIndex, e.Inner.MouseEventArgs, null) == GridHitTestContext.CellButtonElement) { string column = (id.Column != null) ? id.Column.ToString() : ""; string s = "Clicked on " + id.TableCellType.ToString() + "(" + column + ", " + id.DisplayElement.GetType().Name + ")"; MessageBox.Show(s); e.Inner.Cancel = true; } } }
public MultipleButtonGridCell(GridCellRendererBase control) : base(control) { interiorBrush = new BrushInfo(GradientStyle.PathRectangle, Color.NavajoWhite, Color.Beige); }
public CellDragButton(GridCellRendererBase control) : base(control) { interiorBrush = new BrushInfo(GradientStyle.PathRectangle, Color.FromArgb(0x3a, 0x86, 0x7e), Color.FromArgb(204, 212, 230)); }
/// <summary> /// Initializes a <see cref="GridDataBoundTreeCellButton"/> and associates it with a <see cref="GridCellRendererBase"/> /// </summary> /// <param name="control">The <see cref="GridCellRendererBase"/> that draws this cell button element.</param> public GridDataBoundTreeCellButton(GridCellRendererBase control, TreeGridHelper helper) : base(control) { this.helper = helper; iconPainter = new GridIconPaint("TreeGridHelper.", typeof(GridDataBoundTreeCellButton).Assembly); }