views:

23

answers:

1

Using C++/CLI and Windows Forms, I'm trying to make a simple scrollable list of labelled text controls as a way of displaying some data fields. I'm having trouble making a TableLayoutPanel scrollable - every combination of properties I've tried seems to result in some really peculiar side effects.

So I have two questions:

  1. Is this the best way to do it.
  2. If it is a reasonable approach, what magic combination of settings should I apply to the table layout panel to make it play ball?
+1  A: 

TLP is not designed to be scrollable. You'll want a FlowLayoutPanel.

Beware that you'll usually end up with a rather large number of windows which will make your program very slow. Painting becomes noticeably laggy when you get more than about 50 controls in a form. The best solution is a control that can display multiple items but only needs a single Window handle. ListBox, ListView with View = Details, DataGridView are good examples of controls that can do this. They also allow custom painting to tweak their view so you can get it just the way you want it.

Hans Passant
Is there any way to make pairs of labels and text boxes flow as one? Maybe putting each pair in a TableLayoutPanel and then putting those TableLayoutPanels inside a FlowLayoutPanel?
Jon Cage
Create a UserControl for composite controls like that. It isn't a good solution, it is going to be very slow. Use a ListView in Details view or a DataGridView instead.
Hans Passant
+1/Accepted: Listview looks like the way to go after a few experiments - thanks very much!
Jon Cage