I have a program that grabs product data and adds a custom control for each record to a FlowLayoutPanel.
I would like to add a control to the beginning of the FlowLayoutPanel, as opposed to the end, to appear as the first item.
Does anyone have an idea how this is done? I would like to avoid having to repopulate it every time I add an item to the beginning.
You can use the SetChildIndex method of the FlowLayoutPanel's Control collection:
Dim newButton As New Button With {.Text = flp.Controls.Count.ToString}
flp.SuspendLayout()
flp.Controls.Add(newButton)
flp.Controls.SetChildIndex(newButton, 0)
flp.ResumeLayout()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With