greep
asked on
c# Change Listview Column Header text colour.
Hi, I am trying to control the colour of selected List View Column headers at run time.
(I want to indicate to the user if one or more columns have been filtered)
I can see how to change the background. using the DrawColumnHeader event.
e.g.
private void listView1_DrawColumnHeader (object sender, DrawListViewColumnHeaderEv entArgs e)
{
if (colclick == e.ColumnIndex )
{e.Graphics.FillRectangle( Brushes.Ga insboro, e.Bounds);
e.DrawText();}
else
{e.Graphics.FillRectangle( Brushes.Gr eenYellow, e.Bounds);
e.DrawText();}
}
But, how at the same time can I set a column header's text colour?
Thanks
(I want to indicate to the user if one or more columns have been filtered)
I can see how to change the background. using the DrawColumnHeader event.
e.g.
private void listView1_DrawColumnHeader
{
if (colclick == e.ColumnIndex )
{e.Graphics.FillRectangle(
e.DrawText();}
else
{e.Graphics.FillRectangle(
e.DrawText();}
}
But, how at the same time can I set a column header's text colour?
Thanks
Using ForeColor Property you can easily change the Text Color of the Column Header
ASKER
Thanks, but no. e.ForeColor = Color.Blue; does not work
I get build errors.
Property or indexer 'System.Windows.Forms.Draw ListViewCo lumnHeader EventArgs. ForeColor' cannot be assigned to -- it is read only
Is there any way to set this colour at runtime?
I get build errors.
Property or indexer 'System.Windows.Forms.Draw
Is there any way to set this colour at runtime?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
Change the ForeColor property to some Color..