private void gridGroupingControl1_TableControlCellDrawn(object sender, GridTableControlDrawCellEventArgs e) { GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex]; GridTableCellStyleInfoIdentity id = style.TableCellIdentity; Element el = id.DisplayElement; if (el is ExtraSection) { if (id.ColIndex == 0) { // Row Header and ExtraSection is CurrentElement if (el == el.ParentTable.CurrentElement) { // Draw Record indicator try { Rectangle iconBounds = Rectangle.FromLTRB(e.Inner.Bounds.Right - 15, e.Inner.Bounds.Top, e.Inner.Bounds.Right, e.Inner.Bounds.Bottom); iconBounds.Offset(-2, 0); IconPainter.PaintIcon(e.Inner.Graphics, iconBounds, Point.Empty, "SFARROW.BMP", style.TextColor); } catch { } } } } }
void gridGroupingControl1_TableControlCellDrawn(object sender, GridTableControlDrawCellEventArgs e) { if (e.Inner.RowIndex == 1) { Rectangle rect1 = e.Inner.Bounds; rect1.X = (rect1.X + rect1.Width) - 10; rect1.Width = 10; rect1.Y = (rect1.Y + rect1.Height) - 16; rect1.Height = 10; e.Inner.Graphics.DrawLine(new Pen(Color.FromArgb(154, 198, 255)), new Point(rect1.X + 9, rect1.Y - 2), new Point(rect1.X + 9, rect1.Y + 12)); e.Inner.Graphics.DrawLine(Pens.AliceBlue, new Point(rect1.X + 10, rect1.Y - 2), new Point(rect1.X + 10, rect1.Y + 12)); } }
/// <summary> /// Helper routine for drawing picture in covered range of column Employees_Photo. /// </summary> void gridGroupingControl1_TableControlCellDrawn(object sender, GridTableControlDrawCellEventArgs e) { GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.Inner.Style; GridTableCellStyleInfoIdentity id = style.TableCellIdentity; // Employees_Photo column if (id.Column != null && id.Column.MappingName == Employees_Photo) { Group group = id.DisplayElement.ParentGroup; // Grouped by Customers_ContactName if (group != null && group.CategoryColumns.Count > 0 && group.CategoryColumns[0].Name == Customers_ContactName) { if (group.Records.Count > 0) { Record r = group.Records[0]; object value = r.GetValue(id.Column.FieldDescriptor); // Should be byte[] (image stream ...) byte[] byteStream = value as byte[]; if (byteStream != null) { Graphics graphics = e.Inner.Graphics; Image image = GridImageUtil.ConvertToImage(byteStream); Rectangle bounds = e.Inner.Bounds; bounds = GridMargins.RemoveMargins(bounds, style.TextMargins.ToMargins()); bounds = GridMargins.RemoveMargins(bounds, style.BorderMargins.ToMargins()); style.ImageSizeMode = GridImageSizeMode.CenterImage; GridImageUtil.DrawImage(image, bounds, graphics, bounds, style, false); e.Inner.Cancel = true; // signals you did your own drawing. } } } } }