Add a Button dynamically to a flowlayoutpanel in a specific cell in C #. (windows forms)

1

I have a flowlayoupanel in which buttons are added dynamically. This is done with the simple code that we all know:

flowLayoutPanel1.Controls.Add(boton);

However, if you set the Add method, you can not specify a cell as tabletlayoutpanel , how can I tell you by code to add a button in such part of the flowlayoutpanael ? without adding it up or down as stipulated by its attribute flowdirection ?

    
asked by JaviYeri 16.12.2018 в 17:38
source

1 answer

3

In this control there is no concept of "such part" that you mention, you can define a direction using

flowLayoutPanel1.FlowDirection = FlowDirection.RightToLeft; 

to indicate the controls that you add as they are accommodated

Working With Windows Forms FlowLayoutPanel

The closest thing I can think of could be using the SetChildIndex()

flowLayoutPanel1.Controls.SetChildIndex(control, index);

but it is not something exclusive of FlowLayoutPanel but it applies to the collection of controls

Control.ControlCollection.SetChildIndex (Control, Int32) Method

    
answered by 16.12.2018 / 19:33
source