Cam,

Thanks for the help.  I am trying to get the sort part to work.  Seems pretty simple 
as you stated  ... I just need to
figure out HOW to apply it to my program.

My data is stored in a comma delimited file.  Here is the format: (with sample data)

857,Gabe,Skrinjar,Ravine,109-1,00:60:67:25:91:92,141.195.134.100
858,Kelly,Murphy,Schultz,313-2,00:60:67:25:91:9b,141.195.134.101
860,Tara,Dodge,Walker,260-1,00:50:da:c8:ff:7b,141.195.134.102
861,Fabrizio,Polo,Baldwin,A312-1,00:01:02:28:9f:e6,141.195.134.103

I read in the data:

($id,$fname,$lname,$build,$room,$adap,$ip) = split(/,/)

and ignore the $id.

A specifc search is done on all the data based on the "subject" of a tab-click on a 
TabView object. I have three tabs:
Name, Building, and Adapter Address.  For instance: someone wants to get a list of all 
the people whose First and last
names begin with 'M'.  These are displayed in the ListView window.

The data that is displayed needs to be sorted if the user clicks on a tab.

I guerss I don't know how to store the data in a hash to be used with your code.  Any 
ideas?  I can supply the code if
you want.

Jonathan
--------------------------------------------------------------
Jonathan Southwick                              [EMAIL PROTECTED]
Technical and Network Services
Allegheny College
Meadville, PA  16335                             814-332-2755


----- Original Message -----
From: "Cam" <[EMAIL PROTECTED]>
To: "Jonathan Southwick" <[EMAIL PROTECTED]>
Sent: Monday, April 24, 2000 12:56 PM
Subject: Re[2]: [perl-win32-gui] Capturing ListView Clicks


> Hello Jonathan,
>
>         I had to tackle this problem a month or so ago.  The
> function you are using "ListView_ColumnClick" passes the column number
> to this subroutine.  I just 'shifted' it to a variable (See my example
> below).  In my table all my items we stored in a hash.  Each value was
> a list of comma delimited text.  I simply created a new hash with the
> same keys, but the new hash values only had items from the column that
> was click on.  It sounds compilcated, but it works.  Without knowing how
> your data is stored I can't really give you a 'working' example.  I
> included sections of my code to give you a better idea of what I did.
>  I hope this helps... if you have questions just fire them on back.
>
> Cheers.
>
> Perl Code Below
> =============================
>
> #----------------------------------------------------------
> sub ListView_ColumnClick

>     my $col = shift;
>     print "You click on column number $col\n";
>     my %sortonly = &NewList($col,%data);  ## %data is a global variable
>     &SortListItem(/%data,/%sortonly);
> }
>
>
> #----------------------------------------------------------
> sub SortListItem {
>     my ($data,$sortonly,$section) = @_;
>     my $check;
>     my %data = %$data;
>     my %sortonly = %$sortonly;
>
>     $check .= "$_" foreach (values %sortonly); ## Merge all values into 1 string
>
>     if ($check =~ /[a-z]|[A-Z]/g)  { ##--> Compare Num or by Char depending in 
>%sortonly values
>         print "Text Compare!\n";
>         foreach (sort { $sortonly{$a} cmp $sortonly{$b} } keys %sortonly)  {
>              ## Code in here needs to clear the current View
>              ## and then add items all over again.  Just like
>              ## you did when you first created it
>              ## Use the keys that are stored in $_, but get the values
>              ## from the original hash(in this case %data)
>         }
>     } else {
>         print "Number Compare\n";
>         foreach (sort { $sortonly{$b} <=> $sortonly{$a} } keys %sortonly)  {
>              ## Code in here needs to clear the current View
>              ## and then add items all over again.  Just like
>              ## you did when you first created it.
>              ## Use the keys that are stored in $_, but get the values
>              ## from the original hash(in this case %data)
>         }
>     }
> }
>
>
> #----------------------------------------------------------
> sub NewList  {
>     ## This creates another hash to use only for sorting purposes.
>     my ($col,%sortonly) = @_;
>     my $sortthis;
>
>     print "Sorting Using Col#: $col\n";
>
>     foreach (keys %sortonly) {
>         my @info = split /,/, $sortonly{$_};
>         $sortthis = $info[$col];
>         print "Sorting These Items: $sortthis\n";
>         $sortonly{$_} = "$sortthis";
>     }
>     return(%sortonly);
> }
>
>
>
> Monday, April 24, 2000, 09:16:57, you wrote:
>
> JS> Well I figured out how to capture the column click but I don't know how to
> JS> tell which one was clicked. As far as the sorting goes I think you have to
> JS> write your own routine to sort the items and write them back to the listview
> JS> but I could be wrong.
>
> JS> To capture the event:
>
> JS> sub ListView_ColumnClick {
>
> JS> [code in here]
>
> JS> }
>
> JS> So how do I determine exactly what column was clicked?
>
> JS> Jonathan
> JS> --------------------------------------------------------------
> JS> Jonathan Southwick                              [EMAIL PROTECTED]
> JS> Technical and Network Services
> JS> Allegheny College
> JS> Meadville, PA  16335                             814-332-2755
>
> --
> Best regards,
>  Cam                            mailto:[EMAIL PROTECTED]
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
>
>


Reply via email to