C # changing the location of controls inside FlowLayoutPanel

I use flowLayoutPanel to control relative location. I would like to change the location of the control in flowLayoutPanel . when I say location, I do not mean control1 before control2 or something like that - I mean that if I had 2 controls, say label and comboBox - the height of the comboBox is 21, the height of the label is 13 and the height of flowLayoutPanel is 21. I want to put the label in the vertical middle of flowLayoutPanel - ((21-13) / 2) on top. I do not want something specific for the vertical middle. I want a general solution.

+4
source share
3 answers

You can also set the top label field (containerHeight-labelHeight) / 2

+3
source

The layout of the stream will not help: it simply arranges all the controls in the list, adjusting their position to fit into the panel. You can create subgroups by placing controls in a table in the flow layout, or simply use the table for maximum control.

+2
source
  int cIndex = this.FlowLayoutPanel1.Controls.GetChildIndex(Button1); int bIndex = this.FlowLayoutPanel1.Controls.GetChildIndex(Button1); this.FlowLayoutPanel1.Controls.SetChildIndex(Button1, bIndex); this.FlowLayoutPanel1.Controls.SetChildIndex(Button2, cIndex); 
0
source

Source: https://habr.com/ru/post/1340247/


All Articles