mirror of
https://github.com/vinaypamnani/wmie2.git
synced 2025-12-06 04:12:02 +01:00
33 lines
974 B
C#
33 lines
974 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Windows.Forms;
|
|
|
|
namespace WmiExplorer.Classes
|
|
{
|
|
public static class ToolStripItemExtensions
|
|
{
|
|
public static void SortToolStripItemCollection(this ToolStripItemCollection items)
|
|
{
|
|
ArrayList aList = new ArrayList(items);
|
|
aList.Sort(new ToolStripItemCollectionSorter());
|
|
items.Clear();
|
|
|
|
foreach (ToolStripItem item in aList)
|
|
{
|
|
items.Add(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class ToolStripItemCollectionSorter : IComparer
|
|
{
|
|
public int Compare(object x, object y)
|
|
{
|
|
// Cast the objects to be compared to ListViewItem objects
|
|
ToolStripItem toolStripItemX = (ToolStripItem)x;
|
|
ToolStripItem toolStripItemY = (ToolStripItem)y;
|
|
|
|
return String.Compare(toolStripItemX.Text, toolStripItemY.Text, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
}
|
|
} |