Jon Cage
Jon Cage

Reputation: 37500

What's the simplest way to make a scrollable list of controls with labels?

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?

Upvotes: 0

Views: 139

Answers (1)

Hans Passant
Hans Passant

Reputation: 942020

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.

Upvotes: 2

Related Questions