Click here to Skip to main content
15,175,525 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
This question is regarding WinForms ListView control/classes provided by .NET 4.0

My goal is the be able to add a make a listview control that is capable to expand/collapse its item, and once expanded show a containerpanel that can have any controls in in.

I know that i have to use owner draw on this, and that there is a lot of example of mixing the TreeView with a ListView already on the site but none of them suites my needs so thats the main reason I'm opening this post.

I would appreciate some guidelines on this approach, so far I already inherited a from ListViewItem to allow my items to have a expanded/collapsed property and the containerpanel to be draw, but im stuck on the ListView control part, as, for instance, i didn't found a way to "shift" elements down on the listview once a item is expanded to make space to draw the containercontrol.

Is there any way to override the paint and change the bounds on which each item is drawn?

Im using VB.net but i have no troubles translating C# code as well...
Any help on this would be really appreciated.
Posted
Updated 17-Jan-12 1:21am
v3
Comments
   
Do you think there is only one class named ListView? No! You need to tell use fully-qualified name. The UI libraries are so different. You need to tag it: WPF, Forms, what? This is a curse of CodeProject questions. Do you think it's a pleasure to answer in 2-3 variants? No. Why doing extra work if you would use only one variant if any at all. I got an idea, started to type an answer... damn, what's the UI library?
--SA
creizlein 15-Jan-12 5:42am
   
I apologize for that mistake, i was talking about WinForms, but i will improve the question, thanks for the tip..
   
You still did not tag it. When you use "Improve question", the second field will be "Tag". Please add: "WinForms". Please understand, you are the most interested person here. You want attract attention of the right expert before she/he load the question page.
--SA
   

Suggestion to all experts:

We should stop answering UI questions based on assumptions on the library to be used, as well as any other ambiguous questions. Some inquirers probably don't even suspect that there are at least three types named "TextBox". This is not an excuse. Answering based on assumption is not a good option, answering in more than one variant is not an option. We should wait until the inquirer eliminates the ambiguity.


--SA

1 solution

Thank you for compliance and clarification of the question (I up-voted it). It's the best to modify the question itself and leave the notification in a comment. You should also tag the UI library, for your own good. Please see my last comment to the question.

There are some commercial product offering something similar. Let's set them aside; if you need you will be able to find them.

The closest and also the most interesting code I saw in this field is this CodeProject article: Virtual Mode TreeListView[^].

Even more valuable is using the virtual mode in this code. It also would allow you to work with huge amount of data as it is not stored in the control.

Also (I would say, just in case), take a look at this CodeProject article: Collapsible ListViewGroup[^].

Good luck,
—SA
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900