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

Cell Spacing

Thread ID:

Created:

Updated:

Platform:

Replies:

28620 May 5,2005 04:10 PM UTC May 5,2005 05:50 PM UTC Windows Forms 1
loading
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;
}

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.

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

;