Sign in to follow this  
Followers 0
Rahul Rohela

Sort IP ListView

6 posts in this topic

We can sort List View with help of _GUICtrlListViewSort .

Does any one have Idea to sort IP ListView.

As is not sorting IP as per requirment.

Please help to Sort IP Address list view..

Share this post


Link to post
Share on other sites



ANY IDEA???

Share this post


Link to post
Share on other sites

ANY IDEA???

Please Show an example of the data as it is sorting now & an

example of how you were expecting it to sort, then perhaps myself or another

can help you.

--

HardCopy


Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites

Please Show an example of the data as it is sorting now & an

example of how you were expecting it to sort, then perhaps myself or another

can help you.

--

HardCopy

HI

Here i am attaching files. one is example with normal data & second is with IP data.

Its not sorting data as per IP list.

Please check...

thx rahul

_GUICtrlListViewSort.au3

Sort_IP.au3

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

HI

Here i am attaching files. one is example with normal data & second is with IP data.

Its not sorting data as per IP list.

Please check...

thx rahul

Rahul

I had similar problems a while back with sorting pre formatted prices 2.45 , 0.56. 1.52 0.98 etc.

do a search for "sorting prices" you should find that thread.

To get around it i had to pad the numbers to equal lengths with white space

then it will get sorted in the sequence you require.

Here is your SortIP example with the last field of the ip address padded with whitespace to 3 characters.

#include <GuiConstants.au3>
#include <GuiListView.au3>

;Const $LVS_SORTDESCENDING = 0x0020
opt('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index
GUICreate("ListView Sort", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, -1, BitOR($LVS_EX_REGIONAL, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
GUICtrlCreateListViewItem("192.100.100.  2|5data|more_a", $listview);; added whitespace to make 3chars 
GUICtrlCreateListViewItem("192.100.100. 50|4data|more_c", $listview)
GUICtrlCreateListViewItem("192.100.100.  5|3data|more_e", $listview)
GUICtrlCreateListViewItem("192.100.100.105|2data|more_d", $listview)
GUICtrlCreateListViewItem("192.100.100.245|1data|more_b", $listview)
_GUICtrlListViewSetColumnWidth ($listview, 0, 75)
_GUICtrlListViewSetColumnWidth ($listview, 1, 75)
_GUICtrlListViewSetColumnWidth ($listview, 2, 75)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)

GUISetState()

Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview) ]

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
         ExitLoop
        Case $msg = $listview
    ; sort the list by the column header clicked on
            _GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))
   EndSelect
WEnd
Exit

This sorts as you are expecting, but if the IP addresses are not hard coded, you will need to write a routine

that gets the ip address, & pad out the last . xxx field of the address to 3 characters, if not already 3 chars in length.

Someone better qualified than myself, can be more implicit with a solution for you, but i hope this points you

in the right direction.

HardCopy

Edited by HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites

HardCopy Thanks for your priceless help..

Now i will try to figure this out.

Thx

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0