I have a DataGridViewLinkColumn.How can I make the header(row = -1) as underline and change it's background color
var WarningsColumn = new DataGridViewLinkColumn
{
Name = @"Warnings",
HeaderText = @"Warnings",
DataPropertyName = @"WarningsCount",
AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells,
ReadOnly = true
};
Try this:
From the MSDN reference on DataGridView.ColumnHeadersDefaultCellStyle Property:
So you can set it to
False
and then override the defaults, and then you'll end up with something like this (quick and dirty test to make sure it works):Edit:
To apply a style to a single column, use this instead (you'll want to put this after the code where you set the
DataSource
of theDataGridView
):I think you have to add custom code to a
CellPainting
event handler like this:It looks not good but it can help you get started, I think the default background is better. If so, you just need to call:
e.PaintBackground(e.CellBounds, true);
UPDATE
The custom painting should be applied on DoubleBuffered control. So I think you should create your own custom DataGridView like this (it's just a little more code):