CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2011
    Posts
    14

    Using a derived class

    I'm kind of new to C#. I want to use the class below that modifies ListView so that it doesn't flicker. Normally I would just drag over the listview control from the toolbox, edit the properties and modify the events. How would I use the below code to replace the standard ListView? Can someone give me a step by step on how to use this in place of the standard listview control?

    class ListViewNF : System.Windows.Forms.ListView
    {
    public ListViewNF()
    {
    //Activate double buffering
    this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);

    //Enable the OnNotifyMessage event so we get a chance to filter out
    // Windows messages before they get to the form's WndProc
    this.SetStyle(ControlStyles.EnableNotifyMessage, true);
    }

    protected override void OnNotifyMessage(Message m)
    {
    //Filter out the WM_ERASEBKGND message
    if(m.Msg != 0x14)
    {
    base.OnNotifyMessage(m);
    }
    }
    }

  2. #2
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Using a derived class

    I don't know a way how you coudl replace it, especialy not in third party controls. You can only use it in your own controls (controls in your project) instead the standard one. Just drag and drop it from toolbox like standard list view (your list box must be in your solution, othwerwise you have to add it to the toolbox manually). If you want batch replace all listviews in your project, just do search and replace in *.Designer.cs files.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured