views:

960

answers:

5

In our project, SharpWired, we're trying to create a download component similar to the download windows in Firefox or Safari. That is, one single top down list of downloads which are custom controls containing progress bars, buttons and what not.

The requirements are that there should be one single list, with one element on each row. Each element must be a custom control. The whole list should be dynamically re-sizable, so that when you make it longer / shorter the list adds a scroll bar when needed and when you make it thinner / wider the custom controls should resize to the width of the list.

We've tried using a FlowLayoutPanel but haven't gotten resizing to work the way we want to. Preferably we should only have to set anchoring of the custom controls to Left & Right. We've also thought about using a TableLayoutPanel but found adding rows dynamically to be a too big overhead so far.

This must be quite a common use case, and it seems a bit weird to me that the FlowLayoutPanel has no intuitive way of doing this. Has anyone done something similar or have tips or tricks to get us under way?

Cheers!
/Adam

+1  A: 

.NET 3.5 SP1 introduced a DataRepeater Windows Forms control which sounds like it'd do what you want. Bind it to the list of "downloads" (or whatever your list represents) and customize each item panel to include the controls you need.

Matt Hamilton
A: 

@Matt:

.NET 3.5 SP1 introduced a DataRepeater Windows Forms control which sounds like it'd do what you want. Bind it to the list of "downloads" (or whatever your list represents) and customize each item panel to include the controls you need.

That control is in VisualBasic Power Pack. How would I use it in C#?

Adam Lindberg
A: 

@Adam no, it's just in the VisualBasic namespace. You can use it from any and all .NET languages, and it's part of the framework as of .NET 3.5 SP1.

Matt Hamilton
A: 

Adam Lindberg said

That control is in VisualBasic Power Pack. How would I use it in C#?

As far as I know, you may simply reference the assembly in your solution, and use the methods within it as normal. The compiled .Net assemblies can interoperate with each other seamlessly. Of course, I have no specific experince of this assembly, and I can't guarantee anything I've just said in this instance. :)

ZombieSheep
A: 

If you don't want to use databinding (via the DataRepeater control, as mentioned above), you could use a regular Panel control and set its AutoScroll property to true (to enable scrollbars).

Then, you could manually add your custom controls, and set the Dock property of each one to Top.

SLaks
That is what we've been doing. The data binding solution is way too much overhead for us.
Adam Lindberg