문제

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

도움이 되었습니까?

해결책

Use the SetChildIndex method of the Controls' collection:

flp.Controls.SetChildIndex(button3, 1);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top