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.Collecti ons.Generic;
using System.Text;
using System.Windows. Forms;
using System.Drawing;
namespace Workmate
{
public class MyListView : ListView
{
public MyListView()
{
}
protected override void OnPaint(PaintEv entArgs e)
{
SolidBrush drawBrush = new SolidBrush(Back Color); //Use the ForeColor property
e.Graphics.Draw Rectangle(new Pen(drawBrush), 0, 0, Width, Height);
}
protected override void OnEnabledChange d(EventArgs e)
{
Refresh();
}
protected override void OnItemCheck(Ite mCheckEventArgs ice)
{
if (Enabled == true)
{
base.OnItemChec k(ice);
}
}
protected override void OnColumnClick(C olumnClickEvent Args e)
{
base.OnColumnCl ick(e);
Refresh();
}
protected override void OnMouseDown(Mou seEventArgs e)
{
if (Enabled == true)
{
base.OnMouseCli ck(e);
}
else
}
}
}
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.Collecti ons.Generic;
using System.Text;
using System.Windows. Forms;
using System.Drawing;
namespace Workmate
{
public class MyListView : ListView
{
public MyListView()
{
}
protected override void OnPaint(PaintEv entArgs e)
{
SolidBrush drawBrush = new SolidBrush(Back Color); //Use the ForeColor property
e.Graphics.Draw Rectangle(new Pen(drawBrush), 0, 0, Width, Height);
}
protected override void OnEnabledChange d(EventArgs e)
{
Refresh();
}
protected override void OnItemCheck(Ite mCheckEventArgs ice)
{
if (Enabled == true)
{
base.OnItemChec k(ice);
}
}
protected override void OnColumnClick(C olumnClickEvent Args e)
{
base.OnColumnCl ick(e);
Refresh();
}
protected override void OnMouseDown(Mou seEventArgs e)
{
if (Enabled == true)
{
base.OnMouseCli ck(e);
}
else
}
}
}
Comment