AndroidAL
AndroidAL

Reputation: 1119

Possible to sort Labels in FlowlayoutPanel

I have created a FlowLayoutPanel where labels are added dynamically, the label data is taken from a datagridview. Is it possible to sort those labels using a Date column from the datagridview?

Upvotes: 0

Views: 400

Answers (2)

Cenk
Cenk

Reputation: 91

It is possible to order items of any container using the SetChildIndex method.

Here is an example of how to move an item up one place:

 myControl.Parent.Controls.SetChildIndex(
     myControl,  myControl.Parent.Controls.GetChildIndex(myControl) - 1)

Upvotes: 0

Zohar Peled
Zohar Peled

Reputation: 82474

A flow layout panel will keep it's child controls in the order that they are added to it.
This means that you can't sort the controls on it.
Your only options are either to remove all the labels and add then in a different order, or to use a regular panel and then sort the existing label by changing the location property of all the labels.
The first option is, of course, much easier.

Upvotes: 3

Related Questions