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.

GGCTableControlDrawCell issues

Thread ID:

Created:

Updated:

Platform:

Replies:

55958 Feb 7,2007 11:38 AM Feb 14,2007 07:23 PM Windows Forms 5
loading
Tags: GridControl
John H
Asked On February 7, 2007 11:38 AM

Hi,
Please find another example of my nested tables project.

The problem Im seeing now is as follows;
Expand node Table2
Expand sub node Test 1

Problem, the first node within Test 1 is drawing the icon that is drawn on Test 1.

Click on another child node of Test1.

Problem, each node clicked is also drawing the icon that is drawn on Test 1.

Im guessing that the way I detect what table is being drawn in this event is wrong? Im using e.TableControl.TableDescriptor.Name to get the name of the table being drawn which works for the first 2 levels, but not properly for the 3rd.

Any pointers would be appreciated.

Thanks

John



GGC_3_levels_example0.zip

Administrator [Syncfusion]
Replied On February 7, 2007 01:03 PM

Hi John,

You can use the DrawCell event of GridTableControl to achieve this.

grid.GetTableControl("NavParent").DrawCell += new GridDrawCellEventHandler(NavParent_DrawCell);
grid.GetTableControl("Table2").DrawCell += new GridDrawCellEventHandler(Table2_DrawCell);

void Table2_DrawCell(object sender, GridDrawCellEventArgs e)
{
if (e.ColIndex == 3)
{
e.Renderer.Draw(e.Graphics, e.Bounds, e.RowIndex, e.ColIndex, e.Style);
Icon failureIcon = SystemIcons.Error;
Icon warningIcon = SystemIcons.Warning;
Rectangle iRect = new Rectangle(e.Bounds.Width - 100, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawIconUnstretched(warningIcon, iRect);
iRect.X = iRect.X + 80;
e.Graphics.DrawIconUnstretched(failureIcon, iRect);
e.Cancel = true;
}
}

void NavParent_DrawCell(object sender, GridDrawCellEventArgs e)
{
if (e.ColIndex == 3)
{
e.Renderer.Draw(e.Graphics, e.Bounds, e.RowIndex, e.ColIndex, e.Style);
Icon failureIcon = SystemIcons.Error;
Icon warningIcon = SystemIcons.Warning;
Rectangle iRect = new Rectangle(e.Bounds.Width - 100, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawIconUnstretched(warningIcon, iRect);
iRect.X = iRect.X + 80;
e.Graphics.DrawIconUnstretched(failureIcon, iRect);
e.Cancel = true;
}
}

Please refer to the attached sample for modification.
GGCModified.zip

Best Regards,
Haneef

John H
Replied On February 9, 2007 05:22 AM

Hi Haneef,

In your example, Table2_DrawCell is checking e.ColIndex == 3, which is actually the expand collapse icon. Why is it that the first real column is actually at index 4?

Thanks
John

>Hi John,

You can use the DrawCell event of GridTableControl to achieve this.

grid.GetTableControl("NavParent").DrawCell += new GridDrawCellEventHandler(NavParent_DrawCell);
grid.GetTableControl("Table2").DrawCell += new GridDrawCellEventHandler(Table2_DrawCell);

void Table2_DrawCell(object sender, GridDrawCellEventArgs e)
{
if (e.ColIndex == 3)
{
e.Renderer.Draw(e.Graphics, e.Bounds, e.RowIndex, e.ColIndex, e.Style);
Icon failureIcon = SystemIcons.Error;
Icon warningIcon = SystemIcons.Warning;
Rectangle iRect = new Rectangle(e.Bounds.Width - 100, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawIconUnstretched(warningIcon, iRect);
iRect.X = iRect.X + 80;
e.Graphics.DrawIconUnstretched(failureIcon, iRect);
e.Cancel = true;
}
}

void NavParent_DrawCell(object sender, GridDrawCellEventArgs e)
{
if (e.ColIndex == 3)
{
e.Renderer.Draw(e.Graphics, e.Bounds, e.RowIndex, e.ColIndex, e.Style);
Icon failureIcon = SystemIcons.Error;
Icon warningIcon = SystemIcons.Warning;
Rectangle iRect = new Rectangle(e.Bounds.Width - 100, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawIconUnstretched(warningIcon, iRect);
iRect.X = iRect.X + 80;
e.Graphics.DrawIconUnstretched(failureIcon, iRect);
e.Cancel = true;
}
}

Please refer to the attached sample for modification.
GGCModified.zip

Best Regards,
Haneef

John H
Replied On February 9, 2007 06:18 AM

Hi Haneef,
Why is it that DrawCell events are fired for NavParent and Table2 when trying to draw the cell for Table2_2?

Why is it that in Table2_DrawCell, checking for e.ColIndex == 2 renders that child node correctly, but if you expand it, rows for Table2_2 are actually drawing the icons for NavParent? Table2_2 doesn't even have a DrawCell event, why are events for different tables firing on it?

This doesn't make any sense to me as yet, Im hoping you can shed some light on this. Im struggling to see the logic that you have applied here.

Thanks
John

John H
Replied On February 14, 2007 06:49 AM

Hi Haneef,
I still need feedback on this issue as well please.

Thanks
John

>Hi Haneef,
Why is it that DrawCell events are fired for NavParent and Table2 when trying to draw the cell for Table2_2?

Why is it that in Table2_DrawCell, checking for e.ColIndex == 2 renders that child node correctly, but if you expand it, rows for Table2_2 are actually drawing the icons for NavParent? Table2_2 doesn't even have a DrawCell event, why are events for different tables firing on it?

This doesn't make any sense to me as yet, Im hoping you can shed some light on this. Im struggling to see the logic that you have applied here.

Thanks
John

Administrator [Syncfusion]
Replied On February 14, 2007 07:23 PM

Hi John,

Why is it that DrawCell events are fired for NavParent and Table2 when trying to draw the cell for Table2_2?
>>>>
The reason is that you are drawing the inner most child node of the grid.When you draw the inner most child, the grid fisrt draws its parent and than child node.

Why is it that in Table2_DrawCell, checking for e.ColIndex == 2 renders that child node correctly, but if you expand it, rows for Table2_2 are actually drawing the icons for NavParent? Table2_2 doesn't even have a DrawCell event, why are events for different tables firing on it?
>>>>>
The ColIndex of the cell can be changed depends on the indent column and grouping column. Please try the below code find the correct column here.

void Table2_DrawCell(object sender, GridDrawCellEventArgs e)
{
GridTableControl tc = sender as GridTableControl;
int filed = tc.TableDescriptor.ColIndexToField(e.ColIndex);
string columnName = tc.TableDescriptor.VisibleColumns[filed].Name;
if (columnName == "YouColumnName")
{
//your code here....
}
}

Best regards,
Haneef

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.

;