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

Cell Spacing

Thread ID:





28620 May 5,2005 04:10 PM UTC May 5,2005 05:50 PM UTC WinForms 1
Tags: GridControl
Jamie Wright
Asked On May 5, 2005 04:10 PM UTC

Is there a concept of cell spacing within the Syncfusion Grid? By cell spacing, I mean that the grid renders space between the cells. I would lile this because I have a situation where cells in the grid have different back colors and no text. I would like to display space between these cells so that there is some space between the colors. If there is no cell spacing attribute, is there another way to get around this issue?

Administrator [Syncfusion]
Replied On May 5, 2005 05:50 PM UTC

One way you can do this is to handle the DrawCellBackground event and draw the background there yourself. In order for this event to be hit on a particular cell, you must set that cell''s style.Interior = Syncfusion.Drawing.BrushInfo.Empty;. So, for example, you could have code like this:
//in form.load set the styles empty on these cells.
this.gridControl1[2,2].Interior = Syncfusion.Drawing.BrushInfo.Empty;
this.gridControl1[2,3].Interior = Syncfusion.Drawing.BrushInfo.Empty;
this.gridControl1[2,4].Interior = Syncfusion.Drawing.BrushInfo.Empty;
this.gridControl1[3,2].Interior = Syncfusion.Drawing.BrushInfo.Empty;
this.gridControl1[3,3].Interior = Syncfusion.Drawing.BrushInfo.Empty;
this.gridControl1[3,4].Interior = Syncfusion.Drawing.BrushInfo.Empty;
this.gridControl1[4,2].Interior = Syncfusion.Drawing.BrushInfo.Empty;
this.gridControl1[4,3].Interior = Syncfusion.Drawing.BrushInfo.Empty;
this.gridControl1[4,4].Interior = Syncfusion.Drawing.BrushInfo.Empty;

//the handler
private void gridControl1_DrawCellBackground(object sender, GridDrawCellBackgroundEventArgs e)
	Rectangle rect = e.TargetBounds;
	int off = 3;
	rect = new Rectangle(rect.X + off, rect.Y + off, rect.Width - 2 * off, rect.Height - 2 * off);
	Color c = (e.Style.Interior.IsEmpty) ? Color.Red : e.Style.BackColor;
	using (Brush b = new SolidBrush(c))
		e.Graphics.FillRectangle(b, rect);
	e.Cancel = true;


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

or the page will be automatically redirected to 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