[.net] .Net 2005 Inheriting ListView problems
Okay, i don't know what's wrong but i destinctly remembered being able to create a custom control that inherited for example ListView. When i try to pick one of the inherited options in add a new item all i get is to inherit it from a dll or a form that's already in the project.
How can i create a class that inherits the ListView without having to create the class manually since that's only a work-around. :/
[Edited by - Cybrosys on May 19, 2006 4:51:10 PM]
Ok.. I am not sure I am reading this right so can you clarify. Are you trying to instanciate a custom Listview control that you want to manually set the properties of or are you trying to create a Custom Control Listview Class that is inherited from ListView?
theTroll
theTroll
You should subclass the ListView, that is your class should be
public class Whatever : ListView { ...}
If you want to add functionality then you have to make your own class that inherits from ListView.
That should do it for you.
theTroll
class CustomListView : ListView{ public void myCustomFunction() { //... }}
That should do it for you.
theTroll
When i inherit, the class stops being a User control and becomes a Component and i lose the ability to add it to a form from the toolbox.
This will show you how to do it.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppcgen/html/sp_lab1_build_custom_control.asp
theTroll
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppcgen/html/sp_lab1_build_custom_control.asp
theTroll
Quote:Original post by Cybrosys
When i inherit, the class stops being a User control and becomes a Component and i lose the ability to add it to a form from the toolbox.
But you *can* add Components to a form. For example, the Tooltip class inherits from Component.
That being said, I've always thought the tool box was a bit erratic in what it picked up from your own controls and offered for use. For example, if the project containing your custom control/form is under a solution folder, it won't show up in the tool box at all.
What I usually do when inheriting standard controls is just start out with a UserControl, then changing it in the code to inherit from the control I want.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement