Sort en listboxes, comboboxes, etc.

02/12/2003 - 16:49 por JuanI | Informe spam
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body>
<font color="#000066">Hola!<br>
Quisiera saber como hago para ordenar comboboxes, listboxes, etc.<br>
antes de introducir los items los tengo en una arraylist, que s&iacute; tiene
un metodo para Sort, pero utiliza algo llamado Icomparer que no se como
utilizar y la ayuda del vs .net es dificil de entender y no hay
ejemplos.<br>
<b><br>
mi arraylist esta lleno de estructuras:</b></font><br>
&nbsp;<b><font color="#990000">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct inscant<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public string codigo;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public int cantidad;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; private ArrayList listainscant=new ArrayList();</font><br>
<br>
</b><b><font color="#000066">Las listbox las lleno con:<br>
<font color="#990000">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; listBox4b.Items.Clear();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; foreach (inscant temp in listainscant)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; listBox4b.Items.Add(temp.codigo);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
<br>
</font></font></b><b><font color="#000066">Lo que necesito es ordenar
el arraylist antes de llenarlo en la listBox, o preferentemente ordenar
las strings una vez dentro de la listbox.<br>
<font color="#990000"></font><br>
</font></b><br>
<font color="#000066">cualquier ayuda se agradece.</font><br>
<br>
<br>
<br>
<br>
</body>
</html>
 

Leer las respuestas

#1 JuanI
02/12/2003 - 17:52 | Informe spam
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body>
:D<br>
Gracias!<br>
<br>
Julio Novomisky wrote:<br>
<blockquote type="cite" cite="">
<title></title>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<meta name="GENERATOR" content="MSHTML 6.00.2800.1106">
<style></style>
<div>
<p style="margin: 0cm 0cm 0pt;" class="MsoNormal"><span
style="font-size: 8pt;" lang="ES-AR"><o:p><font size="2" face="Arial">Te
cuento unos tips: en el listbox, al cargar el primer item, setale la
propiedad sorted en true (listBox1.Sorted = true<br>
), luego de eso, cargas del elemento segundo, hasta el final, as&iacute; se
ordenan solos</font>&nbsp;</o:p></span></p>
<p style="margin: 0cm 0cm 0pt;" class="MsoNormal"><span
style="font-size: 8pt;" lang="ES-AR"><o:p></o:p></span>&nbsp;</p>
<p style="margin: 0cm 0cm 0pt;" class="MsoNormal"><span
style="font-size: 10pt; font-family: Arial;" lang="ES-AR">Saluditos</span><span
style="font-size: 8pt;" lang="ES-AR"><o:p></o:p></span></p>
<p style="margin: 0cm 0cm 0pt;" class="MsoNormal"><span
style="font-size: 8pt;" lang="ES-AR">&nbsp;<o:p></o:p></span></p>
<p style="margin: 0cm 0cm 0pt;" class="bodytext21"><b><span
style="font-family: Tahoma;" lang="ES-AR">Analista </span></b><b><span
style="font-family: Tahoma;" lang="ES-TRAD">Julio A. Novomisky</span></b><b><span
style="font-family: Tahoma;" lang="ES-TRAD"><o:p></o:p></span></b></p>
<p style="margin: 0cm 0cm 0pt;" class="bodytext21"><span
style="font-size: 7pt; font-family: Tahoma;" lang="ES-TRAD"><a
href="mailto:">mailto:</a><a
href="mailto:"><span
style="font-size: 7.5pt; font-family: 'Courier New';"></span></a><o:p></o:p></span></p>
<p style="margin: 0cm 0cm 0pt;" class="bodytext21"><span
style="font-size: 7pt; font-family: 'Courier New';">Microsoft MVP(C#,
VB .NET, Cobol)<o:p></o:p></span></p>
<p style="margin: 0cm 0cm 0pt;" class="bodytext21"><b><span
style="font-size: 10pt; color: maroon; font-family: 'Courier New';">DevGroup</span></b><span
style="font-size: 7pt; font-family: 'Courier New';"> The Development
Company<o:p></o:p></span></p>
<p style="margin: 0cm 0cm 0pt;" class="bodytext21"><span
style="font-size: 8pt; font-family: 'Arial Narrow';" lang="ES-AR">Ciudad
Aut&oacute;noma de Buenos Aires - Rep&uacute;blica Argentina<o:p></o:p></span></p>
<span style="font-size: 8pt; font-family: 'Arial Narrow';"
lang="ES-AR">Voluntario INETA Latam &#8211; Grupo de Academia</span></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"JuanI" &lt;<a href="mailto:"></a>&gt;
wrote in message <a href="news:">news:</a>...</div>
<font color="#000066">Hola!<br>
Quisiera saber como hago para ordenar comboboxes, listboxes, etc.<br>
antes de introducir los items los tengo en una arraylist, que s&iacute; tiene
un metodo para Sort, pero utiliza algo llamado Icomparer que no se como
utilizar y la ayuda del vs .net es dificil de entender y no hay
ejemplos.<br>
<b><br>
mi arraylist esta lleno de estructuras:</b></font><br>
&nbsp;<b><font color="#990000">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct inscant<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public string codigo;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public int cantidad;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; private ArrayList listainscant=new ArrayList();</font><br>
<br>
</b><b><font color="#000066">Las listbox las lleno con:<br>
<font color="#990000">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; listBox4b.Items.Clear();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; foreach (inscant temp in listainscant)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; listBox4b.Items.Add(temp.codigo);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
<br>
</font></font></b><b><font color="#000066">Lo que necesito es
ordenar el arraylist antes de llenarlo en la listBox, o preferentemente
ordenar las strings una vez dentro de la listbox.<br>
<br>
</font></b><br>
<font color="#000066">cualquier ayuda se agradece.</font><br>
<br>
<br>
<br>
<br>
</blockquote>
</blockquote>
</body>
</html>

Preguntas similares