Jump to content



Photo

How to sort the listview items descending?


  • Please log in to reply
6 replies to this topic

#1 SYRAU3

SYRAU3

    Wayfarer

  • Banned (NOT IN USE)
  • 98 posts

Posted 29 June 2012 - 12:46 PM

Hello big-minds, i have this script:

AutoIt         
#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> $Form1 = GUICreate("Form1", 383, 307, 192, 124) $ListView1 = GUICtrlCreateListView("C1|C2|C3", 56, 16, 257, 241) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50) $ListView1_0 = GUICtrlCreateListViewItem("1|5|6", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("2|7|8", $ListView1) $ListView1_2 = GUICtrlCreateListViewItem("3|9|10", $ListView1) $ListView1_3 = GUICtrlCreateListViewItem("4|11|12", $ListView1) GUISetState(@SW_SHOW) _GUICtrlListView_RegisterSortCallBack($ListView1) _GUICtrlListView_SortItems($ListView1, 2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ListView1 _GUICtrlListView_SortItems($ListView1, GUICtrlGetState($ListView1)) EndSwitch WEnd _GUICtrlListView_UnRegisterSortCallBack($ListView1)


i need to sort the items by the column 3 but descending.. ANY HELP? THANX...







#2 water

water

    ?

  • MVPs
  • 11,167 posts

Posted 29 June 2012 - 12:49 PM

Use function _GUICtrlListView_SimpleSort.

UDFs:

Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts

WordEX (2012-12-29 - Version 1.3 released) - Download

ExcelEX (2013-05-11 - Alpha 4 released) - Download


#3 SYRAU3

SYRAU3

    Wayfarer

  • Banned (NOT IN USE)
  • 98 posts

Posted 29 June 2012 - 12:58 PM

i saw it but i don't know why it's not working... thanx anyway..

#4 water

water

    ?

  • MVPs
  • 11,167 posts

Posted 29 June 2012 - 01:11 PM

Does the _GUICtrlListView_SimpleSort example script work for you?

UDFs:

Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts

WordEX (2012-12-29 - Version 1.3 released) - Download

ExcelEX (2013-05-11 - Alpha 4 released) - Download


#5 Mechaflash

Mechaflash

    Sons of Anarchy

  • Active Members
  • PipPipPipPipPipPip
  • 1,361 posts

Posted 29 June 2012 - 01:21 PM

i saw it but i don't know why it's not working... thanx anyway..


Just looking at doesn't intimidate it into working :D

What's the code you used to perform the sort?
“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

#6 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 7,046 posts

Posted 29 June 2012 - 01:27 PM

Does this work for you?

AutoIt         
#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> $Form1 = GUICreate("Form1", 383, 307, 192, 124) $ListView1 = GUICtrlCreateListView("C1|C2|C3", 56, 16, 257, 241) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50) $ListView1_0 = GUICtrlCreateListViewItem("1|5|6", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("2|7|8", $ListView1) $ListView1_2 = GUICtrlCreateListViewItem("3|9|10", $ListView1) $ListView1_3 = GUICtrlCreateListViewItem("4|11|12", $ListView1) GUISetState(@SW_SHOW) Global $toggle = 1 _GUICtrlListView_SimpleSort($ListView1, $toggle, 2) While 1      $nMsg = GUIGetMsg()      Switch $nMsg          Case $GUI_EVENT_CLOSE              Exit          Case $ListView1              _GUICtrlListView_SimpleSort($ListView1, $toggle, GUICtrlGetState($ListView1))      EndSwitch WEnd


Forgot to initially sort it by the 3rd column descending.

Edited by BrewManNH, 29 June 2012 - 01:30 PM.

How to ask questions the smart way!

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.

Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.

_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image


#7 SYRAU3

SYRAU3

    Wayfarer

  • Banned (NOT IN USE)
  • 98 posts

Posted 29 June 2012 - 09:31 PM

thank's........... that's great! :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users