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. Image for the cookie policy date

turn on column header borders


Hi,

Is there a way to set the column header borders so that they show up when exporting to excel?

4 Replies

HA haneefm Syncfusion Team July 11, 2007 11:02 PM UTC

Hi Code12345,

If you want to affect the column/row headers, handle the Model’s QueryCellInfo event, and set the appropriate style when row zero or column zero is requested.

private void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if( e.RowIndex == 0 )
{
e.Style.Borders.All = new GridBorder(GridBorderStyle.Solid);
}
}

Best regards,
Haneef


JO John July 11, 2007 11:18 PM UTC


Hi Haneef,

Thanks for the input. =) I think I might just try to turn on the column header borders all the time. Could you provide an example of how to do this? Thanks!


HA haneefm Syncfusion Team July 12, 2007 07:37 PM UTC

Hi code12345,

You can conditionally turn ON the border by enable flag before call the GridToExcelExport method and disable it after GridToExcelExport method. You can try the code:

private void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if( IsExcelExport && e.RowIndex == 0 )
{
e.Style.Borders.All = new GridBorder(GridBorderStyle.Solid);
}
}

Best regards,
Haneef


JO John July 12, 2007 09:22 PM UTC


Hi Haneef,

I would like to keep the column header borders on all the time and not just for exporting into excel. What property of the databoundgrid do I need to modify in order to accomplish this? Thanks!


Loader.
Live Chat Icon For mobile
Up arrow icon