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.

Setting Border Color of a Column Header

Thread ID:





73642 May 13,2008 05:28 PM May 14,2008 07:23 AM Windows Forms 1
Tags: GridControl
Julie Levy
Asked On May 13, 2008 05:28 PM

Hi -
I need to draw a vertical line on the gridcontrol. I am using the left border of a column to do so using the following code:
this.Model.ColStyles[i].Borders.Left = new GridBorder(GridBorderStyle.Dashed, Color.Blue, GridBorderWeight.Thin);

However, the column header is not set. When i try and set it seperately using the following code, it is ignored (readonly?). this.Model[0, i].Borders.Left = ...

How can i change the color of the left border of a column header on demand?


Administrator [Syncfusion]
Replied On May 14, 2008 07:23 AM

Hi Julie,

Thanks for the interest in Syncfusion Grid.

You can set the Border of the ColumnHeader by handling PrepareViewStyleInfo event. Please refer the following code snippet that shows how we can hanlde PrepareViewStyleInfo event to set the ColumnHeader of the Grid.

private void Form1_Load(object sender, System.EventArgs e)
for (int i = 1; i <= this.gridControl1.ColCount; i++)
this.gridControl1[0, i].CellValue = string.Format("{0}", Convert.ToChar(64 + i));
for (int i = 1; i <= this.gridControl1.ColCount; i++)
this.gridControl1.Model.ColStyles[i].Borders.Left = new GridBorder(GridBorderStyle.Solid, Color.Blue, GridBorderWeight.Thin);
for (int i = 1; i <= this.gridControl1.RowCount; i++)
this.gridControl1.Model.RowStyles[i].Borders.Top = new GridBorder(GridBorderStyle.Solid, Color.Red, GridBorderWeight.Thin);
this.gridControl1.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(gridControl1_PrepareViewStyleInfo);

private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
if(e.RowIndex == 0 && e.ColIndex > 0)
e.Style.Borders.Left = new GridBorder(GridBorderStyle.Solid, Color.Blue, GridBorderWeight.Thin);
if (e.RowIndex > 0 && e.ColIndex == 0)
e.Style.Borders.Top = new GridBorder(GridBorderStyle.Solid, Color.Red, GridBorderWeight.Thin);

Please refer the following sample that illustrates the above.




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.

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.