Hello All,,,
I am using Following code to change the back color of list view. I don't want the Windows default gray color when Listview is Enable false.so I have crated one class by inheriting the ListView and override some method. OnEnableChange event i just call Refresh. so it paint the background with the color i specified. and in column click event i am sorting the column.. when i click on the column header back color change to widows default Gray. I don't know whats wrong.???
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace Workmate
{
public class MyListView : ListView
{
public MyListView()
{
}
protected override void OnPaint(PaintEventArgs e)
{
SolidBrush drawBrush = new SolidBrush(BackColor); //Use the ForeColor property
e.Graphics.DrawRectangle(new Pen(drawBrush), 0, 0, Width, Height);
}
protected override void OnEnabledChanged(EventArgs e)
{
Refresh();
}
protected override void OnItemCheck(ItemCheckEventArgs ice)
{
if (Enabled == true)
{
base.OnItemCheck(ice);
}
}
protected override void OnColumnClick(ColumnClickEventArgs e)
{
base.OnColumnClick(e);
Refresh();
}
protected override void OnMouseDown(MouseEventArgs e)
{
if (Enabled == true)
{
base.OnMouseClick(e);
}
else
}
}
}