Home > Software design >  How to place two labels in the same line in a TopDown FlowLayoutPanel? C#
How to place two labels in the same line in a TopDown FlowLayoutPanel? C#

Time:12-01

I'm trying to place two labels together like in the picture (while maintaining a TopDown flow) in a FlowLayoutPanel. Is there any way to do this?

Diagram

I tried changing the flow direction to leftToRight for the two labels and changing it back to TopDown afterwards. It did not work.

CodePudding user response:

A FlowLayoutPanel only flows one way. Part of the point is that it will reflow as the content changes, so how could you have it flowing one way for specific controls and another way for others?

If you have configured your FlowLayoutPanel such that it can only have one control per row then it can only have one control per row. If you want two controls on one row then those two controls need to be children of another control and that parent is the one control that you add to the FlowLayoutPanel on that row. The parent could be Panel if you want to do it on an ad hoc basis, or you could create a dedicated user control.

  • Related