custom listview object

A

a

Hi

I would like to add some additional custom features to the listview, like
cell editing. The created object will be added to the form as part of the
GUI, and it should be able to handle events.

I will create a class which conains the listview. Should I inherit this
class from any existing class? If yes, which class should I inherit from?
Or, should I just inherit my class from listview and add my add my
additional features?

Thanks
 
P

Peter Duniho

I would like to add some additional custom features to the listview, like
cell editing. The created object will be added to the form as part of the
GUI, and it should be able to handle events.

I will create a class which conains the listview. Should I inherit this
class from any existing class? If yes, which class should I inherit from?
Or, should I just inherit my class from listview and add my add my
additional features?

I would think that inheriting from the ListView class itself is the best
approach. You could extend it by composition (which is the other approach
you're talking about, by containing the ListView class in a new class
rather than inheriting it), but then you will have to forward every single
method and property that you want to be able to use of the ListView
class. That's potentially a lot of work. If you inherit it, then all of
that is done automatically.

Inheriting also gives you better access to the internal stuff in
ListView. In particular, protected members that might be useful in your
extending it. And even more particularly: the WndProc method. I don't
know about the ListView class specifically, but all of the controls in the
Forms namespace that I've messed with are just wrappers around a native
Win32 control.

As such, most of the interesting stuff actually happens in the control's
window proc, rather than the .NET class methods. Overriding things like
MouseDown, MouseMove, MouseUp, KeyDown, KeyUp, etc. does not actually get
you full control to the control's behavior, the way that overriding
WM_LBUTTONDOWN, WM_MOUSEMOVE, etc. in the native Win32 environment would.
You still need to override those specific native Win32 window messages,
and that's done in the WndProc method.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top