The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I am using TableControlCellDrawn to drawimage within a column of my GridGroupingControl. Works fine when there are no groups, but when I group a column or 2, I am finding it hard to get the current record. My method is:
private void grdScenario_TableControlCellDrawn(object sender, GridTableControlDrawCellEventArgs e) { GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo; int _groupedColsCnt = -1; int _rowIndex = -1; int _totalRecsCnt = -1;
if (style.TableCellIdentity.TableCellType != GridTableCellType.ColumnHeaderCell && style.TableCellIdentity.Column != null && style.TableCellIdentity.Column.Name == "Image") { _groupedColsCnt = e.TableControl.TableDescriptor.GroupedColumns.Count; _rowIndex = (style.TableCellIdentity.RowIndex - 3); _totalRecsCnt = this.grdScenario.Table.Records.Count; if(_rowIndex < _totalRecsCnt && _rowIndex >= 0) { Record _rec = this.grdScenario.Table.Records[_rowIndex]; if(_rec == null) return; bool _isRef = ((_rec.GetValue("isReference") != System.DBNull.Value)?Convert.ToBoolean(_rec.GetValue("isReference")):false); if(_isRef) GridStaticCellRenderer.DrawImage(e.Inner.Graphics, this.images, 2, e.Inner.Bounds, false); else GridStaticCellRenderer.DrawImage(e.Inner.Graphics, this.images, 0, e.Inner.Bounds, false); } } } Any ideas on how to get the exact _rowIndex given the GroupedColumns?
LSLingaraj S Syncfusion Team April 22, 2009 06:19 PM UTC
Hi,
Thank you for your interest in Syncfusion products.
The provided code gets the record through the rowindex. The rowindex of record used to change on grouping. Only through the current display element, appropriate record can be accessed.Please try using the DisplayElement in TableControlDrawCell to avoid this issue.
Please refer the code below: private void gridGroupingControl1_TableControlDrawCell(object sender, GridTableControlDrawCellEventArgs e) { GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo; if (style.TableCellIdentity.TableCellType != GridTableCellType.ColumnHeaderCell && style.TableCellIdentity.Column != null && style.TableCellIdentity.Column.Name == "Image") { Element el = style.TableCellIdentity.DisplayElement; if (el != null && el.Kind == DisplayElementKind.Record) { Record r = el.GetRecord(); if (r == null) return; bool _isRef = ((r.GetValue("Credit").ToString() != "0") ? true : false); if (_isRef) GridStaticCellRenderer.DrawImage(e.Inner.Graphics, this.imglist, 3, e.Inner.Bounds, false); else GridStaticCellRenderer.DrawImage(e.Inner.Graphics, this.imglist, 0, e.Inner.Bounds, false); } } }