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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Drawing Rectangle in a Grid Cell

Thread ID:





54295 Jan 5,2007 08:29 AM UTC Jan 5,2007 10:08 AM UTC WinForms 1
Tags: GridControl
Asked On January 5, 2007 08:29 AM UTC

Hi Haneef ... i want to draw a rectangle of specified color before text in a grid cell .. how can i do this ??

Ubaid Tariq

Administrator [Syncfusion]
Replied On January 5, 2007 10:08 AM UTC

Hi Ubaid,

You can handle the DrawCell event to draw the rectangel before the cell text in a grid cell. Please try the attached sample and let me know if this helps.

Sample : DrawRectangleCell.zip

private void gridControl1_DrawCell(object sender, GridDrawCellEventArgs e)
if(e.RowIndex > 0 && e.ColIndex > 0)
if( e.Style.Text != null && e.Style.Text != string.Empty )
e.Style.TextMargins.Left = 5;
e.Graphics.FillRectangle(Brushes.Red,new Rectangle(e.Bounds.X,e.Bounds.Y,5,17));
e.Cancel = true;

Best Regards,


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon