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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Setting Border Color of a Column Header

Thread ID:

Created:

Updated:

Platform:

Replies:

73642 May 13,2008 09:28 PM UTC May 14,2008 11:23 AM UTC WinForms 1
loading
Tags: GridControl
Julie Levy
Asked On May 13, 2008 09:28 PM UTC

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?

Thanks,
Julie
Than


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

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.

http://websamples.syncfusion.com/samples/Grid.Windows/F73642/main.htm

Regards,
Asem.



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

;