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. Image for the cookie policy date

Drawing Image for boolean value instead of checkbox...

Hi,
I am using GDBG version 4.4.x.x ( latest version)
I have grid which is data display purposes only.
As far as the checkbox go, they look clickable.

Hence I need to draw a checkmark for the true value, instead of letting Grid draw checkbox.

I am able to do that only problem is, if I do the drawing by proving ImageIndex and stuff, it get's drawn to the far left in the column.

If I use the CellDrawn event, the image is getting drawn in the center but it also draws the true or false values.

I tried several things to get rid of the text portion but with no luck so far.

Do you have any advice for me on how I can acheive this?

Thanks,
Pratima

5 Replies

HA haneefm Syncfusion Team May 21, 2007 07:38 PM UTC

Hi Pratima,

You need to create a custom celltype. It requires a model class and a renderer class. The model class handles the serialization requirements for the control and creates the renderer class. The renderer class handles the UI requirements of the cell. In that reandere class you need to override the OnDraw method to draw required image in a cell. Please refer to the attachment for implemention and let me know if this helps.

Sample : BooleanImageCellType.zip

Best regards,
Haneef


PR Pratima May 21, 2007 07:51 PM UTC

Thanks I will take a look.
Alternatively,
Is there a way to not draw the checkbox borders but just to draw the check inside it? or procedure you suggested is the only way?

Thanks,
Pratima

>Hi Pratima,

You need to create a custom celltype. It requires a model class and a renderer class. The model class handles the serialization requirements for the control and creates the renderer class. The renderer class handles the UI requirements of the cell. In that reandere class you need to override the OnDraw method to draw required image in a cell. Please refer to the attachment for implemention and let me know if this helps.

Sample : BooleanImageCellType.zip

Best regards,
Haneef


HA haneefm Syncfusion Team May 21, 2007 08:43 PM UTC

Hi Pratima,

You can do this by handling the DrawCell event of the grid and draw checked mark by using the DrawLines method. Please refer this forum thread for more details and let me know if this helps.

Best regards,
Haneef


PR Pratima May 21, 2007 09:48 PM UTC

Hi Haneef,
Actually I found a way to not displaying text by setting TextColor to transparent in PrepareViewstyleInfo event and drawing the image in CellDrawn event..

I know it's cheating however works for my case.
Just thought will let you know just in case anybody else has same usecase as I did.

Thanks,
Pratima


>Hi Pratima,

You can do this by handling the DrawCell event of the grid and draw checked mark by using the DrawLines method. Please refer this forum thread for more details and let me know if this helps.

Best regards,
Haneef


HA haneefm Syncfusion Team May 21, 2007 11:14 PM UTC

Hi Pratima,

You can use DrawCellDisplayText event and set e.DisplayText there to easily control what text is drawn in the cell. Below is a code snippet.

private void gridControl1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if( e.ColIndex == 5)
e.Cancel = true; //Cancel the default drawing.
}

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon