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.
Syncfusion Feedback

Drawing Rectangle in a Grid Cell

Thread ID:





54295 Jan 5,2007 03:29 AM Jan 5,2007 05:08 AM Windows Forms 1
Tags: GridControl
Asked On January 5, 2007 03:29 AM

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 05:08 AM

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.

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