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.

Cell icon

Thread ID:

Created:

Updated:

Platform:

Replies:

61978 Jun 5,2007 12:16 PM Jun 7,2007 02:23 PM Windows Forms 6
loading
Tags: GridControl
m.n.m,n.mn
Asked On June 5, 2007 12:16 PM

i have a column, the column cells for certain rows must contain a custom icon i made....
So i want for some cells of that column to have an icon, and others to be blank...where i'm gonna put the icon is determined by the value of the row cell, that is, if the cell has value show the icon, and if it's null show nothing...

There's a rough picture in the attachment...

The black stains represent the places where to put the icon..I'm fillin that column from a database, and when the columns are filled, i want there to be an icon in the places where the value exists,and where the value is not null (in the database).

Thanx..p.s. sorry for the bad picture :)

cellIcon.zip

haneefm [Syncfusion]
Replied On June 5, 2007 01:41 PM

Hi Mario,

You can do this by handling the TableControlDrawCell event of the grid and draw image by using the Graphics.DrawXXX method. Below is a code snippet

void gridGroupingControl1_TableControlDrawCell(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlDrawCellEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
Element el = style.TableCellIdentity.DisplayElement;

if (el.Kind == DisplayElementKind.Record && style.TableCellIdentity.Column != null
&& style.TableCellIdentity.Column.Name == "Col 1")
{
if (style.CellValue != null || style.CellValue.ToString() != string.Empty)
{
e.Inner.Cancel = true;
e.Inner.Graphics.DrawIcon(SystemIcons.Question, e.Inner.Bounds);
}
}
}

Best regards,
Haneef

m.n.m,n.mn
Replied On June 5, 2007 03:18 PM



>Hi Mario,

You can do this by handling the TableControlDrawCell event of the grid and draw image by using the Graphics.DrawXXX method. Below is a code snippet

void gridGroupingControl1_TableControlDrawCell(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlDrawCellEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
Element el = style.TableCellIdentity.DisplayElement;

if (el.Kind == DisplayElementKind.Record && style.TableCellIdentity.Column != null
&& style.TableCellIdentity.Column.Name == "Col 1")
{
if (style.CellValue != null || style.CellValue.ToString() != string.Empty)
{
e.Inner.Cancel = true;
e.Inner.Graphics.DrawIcon(SystemIcons.Question, e.Inner.Bounds);
}
}
}

Best regards,
Haneef


Hi Haneef,
i tried your snippet, but i got the same thing where i myself stuck :), the event fill all cells no matter if there's a value, and the icon is large, it spreads through the entire cell...

Example in the attachement...



CellIcon0.zip

haneefm [Syncfusion]
Replied On June 5, 2007 03:33 PM

Hi Mario,

You can try these code snippet:

GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
Element el = style.TableCellIdentity.DisplayElement;

if (el.Kind == DisplayElementKind.Record && style.TableCellIdentity.Column != null && style.TableCellIdentity.Column.Name == "Stup")
{
if (style.CellValue != null && style.CellValue.ToString() != string.Empty)
{
e.Inner.Cancel = true;
e.Inner.Graphics.DrawIcon(SystemIcons.Question, e.Inner.Bounds);
}
}

Best regards,
Haneef

m.n.m,n.mn
Replied On June 5, 2007 03:42 PM



>Hi Mario,

You can try these code snippet:

GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
Element el = style.TableCellIdentity.DisplayElement;

if (el.Kind == DisplayElementKind.Record && style.TableCellIdentity.Column != null && style.TableCellIdentity.Column.Name == "Stup")
{
if (style.CellValue != null && style.CellValue.ToString() != string.Empty)
{
e.Inner.Cancel = true;
e.Inner.Graphics.DrawIcon(SystemIcons.Question, e.Inner.Bounds);
}
}

Best regards,
Haneef


Thanx Haneef, it's working now, but there's still the "huge" icon problem....the icon stretches itself through the cell...

haneefm [Syncfusion]
Replied On June 5, 2007 05:41 PM

Hi Mario,

You can specify the location and size of the resulting image on the display surface in DrawIcon method. Please try the below code snippet to display image at center of the gridcell and let me know if this helps.

Rectangle _rectCenter = GridUtil.CenterInRect(e.Inner.Bounds, SystemIcons.Question.Size);
e.Inner.Graphics.DrawIcon(SystemIcons.Question, _rectCenter );

Best regards,
Haneef

m.n.m,n.mn
Replied On June 7, 2007 02:23 PM



>Hi Mario,

You can specify the location and size of the resulting image on the display surface in DrawIcon method. Please try the below code snippet to display image at center of the gridcell and let me know if this helps.

Rectangle _rectCenter = GridUtil.CenterInRect(e.Inner.Bounds, SystemIcons.Question.Size);
e.Inner.Graphics.DrawIcon(SystemIcons.Question, _rectCenter );

Best regards,
Haneef


Thanx Haneef, it's working fine now..

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.

;