|
-
November 8th, 2011, 01:31 AM
#1
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);
}
}
}
-
November 8th, 2011, 02:53 AM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|