Visual Basic - Ordenar Numeros en un ListView

Life is soft - evento anual de software empresarial
 
Vista:

Ordenar Numeros en un ListView

Publicado por carlos pulga (136 intervenciones) el 01/02/2007 14:33:01
tengo este codigo para organizar un listview

Select Case ColumnHeader
Case "Muestras"
If LstPrecios.SortOrder = lvwAscending Then
LstPrecios.SortKey = 1
LstPrecios.SortOrder = lvwDescending
Else
LstPrecios.SortKey = 1
LstPrecios.SortOrder = lvwAscending
End If
Case "Precios: Lista 1"
If LstPrecios.SortOrder = lvwAscending Then
LstPrecios.SortKey = 2
LstPrecios.SortOrder = lvwDescending
Else
LstPrecios.SortKey = 2
LstPrecios.SortOrder = lvwAscending
End If
End Select

el primer case la hace bien, lo organiza por orden alfabetico, pero el segundo no la hace bien, lo deberia organizar por orden numerico pero lo hace en orden alfabetico me explico primero 0 despues 1 sea cual sea la cifra despues 2, claro esta todo esto si esta en el primer numero de la cifra y respetando la segundo , tercero y cuarto numero como se hace en el caso de ordenar palabras, me podrian decir como soluciono este problema
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ordenar Numeros en un ListView

Publicado por lolo (67 intervenciones) el 01/02/2007 20:07:22
hace años lei en web del guille un ejemplo de como hacer eso, ahora no me acuerdo exactamente pero el truco consistia en convertir la columna a string y rellenarle unos cuantos ceros por delante, ordenar como string y volverlo a poner en formato numérico.
puedes desarrollar la idea o intentar buscar ese ejemplo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Ordenar Numeros en un ListView

Publicado por eltaliba (1 intervención) el 01/02/2007 21:02:41
si no sabes para ke contestas ??
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Ordenar Numeros en un ListView

Publicado por lolo (67 intervenciones) el 01/02/2007 22:20:13
y tu si eres subnormal pork respondes?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Ordenar Numeros en un ListView

Publicado por carlos pulga (136 intervenciones) el 02/02/2007 15:58:29
bueno dejen la estupides garcias por el consejo lolo aunque no fue muy exacta pero em ayudo. despues de intentar muchas cosas el codigop es mas o menos asi:

Private Sub LstPrecios_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
Dim RgsT As Long
Dim Ds As Long
Select Case ColumnHeader
Case "Muestras"
If LstPrecios.SortOrder = lvwAscending Then
LstPrecios.SortKey = 1
LstPrecios.SortOrder = lvwDescending
Else
LstPrecios.SortKey = 1
LstPrecios.SortOrder = lvwAscending
End If
Case "Precios: Lista 1"
RgsT = LstPrecios.ListItems.Count
For Ds = 1 To RgsT
If Len(LstPrecios.ListItems.Item(Ds).SubItems(2)) = 10 Then
LstPrecios.ListItems.Item(Ds).SubItems(2) = String$(1, "0") & _
LstPrecios.ListItems.Item(Ds).SubItems(2)
End If
If Len(LstPrecios.ListItems.Item(Ds).SubItems(2)) = 9 Then
LstPrecios.ListItems.Item(Ds).SubItems(2) = String$(2, "0") & _
LstPrecios.ListItems.Item(Ds).SubItems(2)
End If
If Len(LstPrecios.ListItems.Item(Ds).SubItems(2)) = 8 Then
LstPrecios.ListItems.Item(Ds).SubItems(2) = String$(3, "0") & _
LstPrecios.ListItems.Item(Ds).SubItems(2)
End If
If Len(LstPrecios.ListItems.Item(Ds).SubItems(2)) = 7 Then
LstPrecios.ListItems.Item(Ds).SubItems(2) = String$(4, "0") & _
LstPrecios.ListItems.Item(Ds).SubItems(2)
End If
If Len(LstPrecios.ListItems.Item(Ds).SubItems(2)) = 6 Then
LstPrecios.ListItems.Item(Ds).SubItems(2) = String$(5, "0") & _
LstPrecios.ListItems.Item(Ds).SubItems(2)
End If
If Len(LstPrecios.ListItems.Item(Ds).SubItems(2)) = 5 Then
LstPrecios.ListItems.Item(Ds).SubItems(2) = String$(6, "0") & _
LstPrecios.ListItems.Item(Ds).SubItems(2)
End If
If Len(LstPrecios.ListItems.Item(Ds).SubItems(2)) = 4 Then
LstPrecios.ListItems.Item(Ds).SubItems(2) = String$(7, "0") & _
LstPrecios.ListItems.Item(Ds).SubItems(2)
End If
Next
If LstPrecios.SortOrder = lvwAscending Then
LstPrecios.SortKey = 2
LstPrecios.SortOrder = lvwDescending
Else
LstPrecios.SortKey = 2
LstPrecios.SortOrder = lvwAscending
End If
For Ds = 1 To RgsT
LstPrecios.ListItems.Item(Ds).SubItems(2) = FormatNumber _
(LstPrecios.ListItems.Item(Ds).SubItems(2), 2)
Next
End Select
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar