Pergunta

I have a FlowLayoutPanel that users add buttons dinamically. I worked out the code to add the buttons on the panel, the problem I have now is that my buttons are not sorted by name. Instead the buttons show up in the order they were created.

How can I sort the buttons automatically once a new button is created? Can this be done, or am I using the wrong type of panel?

Here is an image of the panel with my buttons, this one appears sorted because it was the initial panel I created.enter image description here

Foi útil?

Solução

Use the SetChildIndex method of the Controls' collection:

flp.Controls.SetChildIndex(button3, 1);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top