I populate DropDownButton by xml nodes
foreach (System.Xml.XmlNode node in kats.SelectNodes("Kats/Kat"))
{
btnKats.DropDownItems.Add(node.InnerText);
}
And need to sort the items, somethig like:
btnKats.DropDownItems.Sort... // how can I do this
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t.
But you can do this:
The rationale is that DropDownItems is a ToolStripItemCollection that implements a plain IList (of objects). As objects are not naturally comparable, you can’t sort an IList, but you can cast it to a List<string> and sort it.
http://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripitemcollection.aspx
Good luck!