Probelm in changing Backcolor of Listview

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • phpfreak2007
    replied
    Originally posted by sanatpalia
    May be your onPaint event is happening before the Refresh(). So you loose the background color


    Sanat Palia

    I dont know the exact flow of event. that which event will first and which after that..if on paint is happning before refresh(). how to overcome that?

    Leave a comment:


  • sanatpalia
    replied
    May be your onPaint event is happening before the Refresh(). So you loose the background color


    Sanat Palia

    Leave a comment:


  • sanatpalia
    replied
    May be your onPaint event is happening before the Refresh(). So you loose the background color

    Leave a comment:


  • phpfreak2007
    started a topic Probelm in changing Backcolor of Listview

    Probelm in changing Backcolor of Listview

    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

    }



    }
    }
Working...