Implementing an Extension to Sort ControlCollection in .NET 3.5
public static class SortingExtension
{
public static void Sort<T>(this System.Windows.Forms.Control.ControlCollection c) where T : class
{
for(int i=1; i<c.Count; i++)
{
IComparable<T> ctl = c
as IComparable<T>;
T pCtl = c[i - 1] as T;
if (ctl != null && pCtl != null)
if (ctl.CompareTo(pCtl) > 0)
c.SetChildIndex(c
, c.GetChildIndex(c
) - 1);
}
}
}
I will detailed a little more later this implementation.
-f.