Sign in to follow this  
Cybrosys

[.net] .Net 2005 Inheriting ListView problems

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
If you want to add functionality then you have to make your own class that inherits from ListView.


class CustomListView : ListView
{
public void myCustomFunction()
{
//...
}

}




That should do it for you.

theTroll

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this