We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

TableCellIdentity.RowIndex and GroupedColumns

Thread ID:

Created:

Updated:

Platform:

Replies:

80665 Apr 21,2009 10:37 AM Apr 22,2009 02:19 PM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On April 21, 2009 10:37 AM

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?



Lingaraj S [Syncfusion]
Replied On April 22, 2009 02:19 PM

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);
}
}
}


Please let me know if you have any queries.

Regards,
Lingaraj S.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;