altgov3en
altgov3en

Reputation: 1206

Append multiple UserControls to WinForm Panel

I'm trying to append multiple UserControls to my WinForm Panel.

At first, the Controls.Add() function was adding the UserControls one above the other. But then I figured out that I need to use Dock property. I've changed the Dock property of the UserControl to DockStyle.Left and this is what I've got:

enter image description here

But when I tried to add another UserControl this is what I've got:

enter image description here

The added UserControl leaked out of the panel.

I want the new UserControl to be appended in the new line if there not enough space for the previous line to contain the UserControl.

I would expect to see something like that:

enter image description here

How can I achieve the desired result?

Upvotes: 2

Views: 3977

Answers (1)

altgov3en
altgov3en

Reputation: 1206

Thanks to @IvanStoev I solved the problem.

What I needed to do is to change my Panel to FlowLayoutPanel. FlowLayoutPanel arranges himself the appended UserControls.

Upvotes: 2

Related Questions