Search code examples
c#sortingdatagridviewlabelflowlayoutpanel

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?


Solution

  • 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.