Tim,


Thanks for your help with this

I realised that as I was supplying the data to the list box I just needed to put it into an array and use:

sub ListView_ItemClick {
        $item = shift;
        print $asset[$item];
       
}



Regards


Mike Solomon
Technical Manager
Work     01582 831125
Mobile 07941 537 172
email   msolomon@3s-technology.com

==================================================================================
Important: Any views or opinions expressed by the sender do not necessarily
represent those of the 3s Group. This e-mail and any attachment(s)
are intended for the above named only and may be confidential.  If you are not
the named recipient please notify us immediately.  You must not copy or disclose
the contents to any third party.

Internet e-mail is not a fully secure communications medium.  Please take
this into account when sending e-mail to us.
Any attachment(s) to this e-mail are believed to be free from virus, but it
is the responsibility of the recipient to make all the necessary virus
checks.

www.3s-group.com

=========================================================================

 -----Original Message-----
From:   Thomas, Timothy B [mailto:timothy.b.thomas@lmco.com]
Sent:   15 February 2001 17:45
To:     'perl-win32-gui-users@lists.sourceforge.net'
Subject:        RE: [perl-win32-gui-users] get value from list

There is a SelectedItems function you can use.
Here's a bit of code that will get the data from all the selected items.
Once you determine which item you have selected you can use that other piece
of code to get the data from every column, or you can use this example if
you just want the first column.
see the documentation at http://dada.perl.it/gui_docs/gui.html for more
help.

        if ($ListView->SelectCount() gt 0)
                {
                for $i(0..$ListView->SelectCount()-1)
                        {
       
%data=$ListView->ItemInfo(($ListView->SelectedItems)[$i]);
                        $filename=$data{-text};
                        ...

----------------------------------------------------------------------------
---------------------
Tim Thomas
Unix Systems Administrator
Lockheed Martin EIS Denver Data Center
303-430-2281
mailto:timothy.b.thomas@lmco.com
----------------------------------------------------------------------------
---------------------
-----Original Message-----
From: Michael Solomon [mailto:MSolomon@3s-technology.com]
Sent: Thursday, February 15, 2001 10:32 AM
To: 'perl-win32-gui-users@lists.sourceforge.net'
Subject: RE: [perl-win32-gui-users] get value from list


Tim,
Thanks for this
Unfortunately this gets all the items from the list
What I want to do is to click on an item in the list and just capture that
For example
If I have a list showing
1
2
3
if I click on the 3, I want to capture 3
I hope this makes sense


Regards


Mike Solomon
Technical Manager
Work     01582 831125
Mobile 07941 537 172
email   msolomon@3s-technology.com
============================================================================
======
Important: Any views or opinions expressed by the sender do not necessarily
represent those of the 3s Group. This e-mail and any attachment(s)
are intended for the above named only and may be confidential.  If you are
not
the named recipient please notify us immediately.  You must not copy or
disclose
the contents to any third party.
Internet e-mail is not a fully secure communications medium.  Please take
this into account when sending e-mail to us.
Any attachment(s) to this e-mail are believed to be free from virus, but it
is the responsibility of the recipient to make all the necessary virus
checks.
www.3s-group.com
=========================================================================
 -----Original Message-----
From:   Thomas, Timothy B [mailto:timothy.b.thomas@lmco.com]
Sent:   15 February 2001 16:48
To:     'perl-win32-gui-users@lists.sourceforge.net'
Subject:        RE: [perl-win32-gui-users] get value from list
Someone else has written a win32::Gui program to do just what you are trying

to do. I don't seem to have the code anymore. Maybe they can post it again,
or you can search the archives.
Here's a piece of code I just wrote that gets all the data, including the
image, from a listview, it puts it into a hash.
I used this with the column sort routine that has been floating around, by
Jonathan Southwick [jsouthwi@allegheny.edu]. I am still working out the
bugs, but this section of code should help you.
        # you must already have $totalcols (the # of columns in your
listview)
        #       I don't think there is a way to pull this from the object.
        %data=();
        $rows=$ListView->Count();
        for $i(0..$rows-1)
                {
                $row="";
                my %result=$ListView->GetItem($i,0);
                $image=$result{-image};
                for $j(0..$totalcols-1)
                        {
                        my %result=$ListView->GetItem($i,$j);
                        $text=$result{-text};
                        $row.=",$text";
                        }
                $data{$i}="$image$row";
                #Win32::MsgBox("data($i)=$image$row\n");
                }


----------------------------------------------------------------------------

---------------------
Tim Thomas
Unix Systems Administrator
Lockheed Martin EIS Denver Data Center
303-430-2281
mailto:timothy.b.thomas@lmco.com
----------------------------------------------------------------------------

---------------------
-----Original Message-----
From: Michael Solomon [mailto:MSolomon@3s-technology.com]
Sent: Thursday, February 15, 2001 5:19 AM
To: Perl Gui (E-mail)
Subject: [perl-win32-gui-users] get value from list


I am querying a database and putting the output into a listview
What I would like to next is to click on an item in the list and then
drilldown into the data base
The question is how can I return the value from a List
I am fairly new at using Win32::GUI and apologise if this is a stupid
question.
Should I be using a different type than listview and if so what should I be
using?



use strict;
use Socket;
use Win32::GUI;
use Win32::ODBC;
#set variables
my (%Data, %new, $result, $Window, $width);
my $Dir                 = "//neptune/tech_dept/databases";
my $DBase               = "asset.mdb";
my $DriverType  = "Microsoft Access Driver (*.mdb)";
my $Desc                = "Description=The Win32::ODBC Test DSN for Perl";
my $DSN                 = "tmpdsn";
$Window = new GUI::Window(
    -name   => "Window",
    -text   => "Win32::GUI::ListView test",
    -width  => 350,
    -height => 500,
    -left   => 100,
    -top    => 100,
);


$Window->AddListView(
    -name      => "ListView",
    -left      => 10,
    -top       => 10,
    -width     => 330,
    -height    => 383,
    -style     => WS_VISIBLE | 1,
    -gridlines => 1,
);
$width = $Window->ListView->ScaleWidth;
$Window->ListView->InsertColumn(
    -index => 0,
    -width => $width/2,
    -text  => "Asset No",
);
$Window->ListView->InsertColumn(
    -index   => 1,
    -width   => $width/2,
    -text    => "IP Address",
);
$Window->AddRadioButton(
        -name    => "Radio1",
        -left    => 8,
        -top     => 410,
        -text    => "192 Network  ",
        -tabstop => 1,
);
$Window->AddRadioButton(
        -name    => "Radio2",
        -left    => 8,
        -top     => 430,
        -text    => "212 XTML  ",
        -tabstop => 1,
);


$Window->AddRadioButton(
        -name    => "Radio3",
        -left    => 8,
        -top     => 450,
        -text    => "212 EasyNet  ",
        -tabstop => 1,
);
#$Window->ListView->TextColor(hex("0000FF"));
$Window->Show();
$Window->Dialog();


sub MAIN {
        #set up dsn
        Win32::ODBC::ConfigDSN(ODBC_ADD_DSN, $DriverType, ("DSN=$DSN",
"Description=The Win32 ODBC Test DSN for Perl", "DBQ=$Dir\\$DBase",
"DEFAULTDIR=$Dir", "UID=", "PWD="));
        #open connection as $0
        my $cO = new Win32::ODBC($DSN);
        #run sql
        $cO->Sql("SELECT assetid, ipaddress FROM ip_address where ipaddress
like '${result}%'");
        #reset new
        %new = ();
        # Fetch the next rowset
        while($cO->FetchRow()){
                %Data = $cO->DataHash();
                #convert to binary
                $new{inet_aton($Data{ipaddress})} =
"$Data{assetid},$Data{ipaddress}";
        }
        #close database
        $cO->Close();
        #remove tempdsn
        Win32::ODBC::ConfigDSN(ODBC_REMOVE_DSN, $DriverType, "DSN=$DSN");
        #clear items
        $Window->ListView->Clear(); 
        foreach (sort keys %new) {
                        my ($asset, $ip ) = split(",",$new{$_});
                $Window->ListView->InsertItem(-text => [ "$asset", "$ip" ]
);
        };
}


sub MAIN1 {
        #clear items
        $Window->ListView->Clear(); 
        foreach (sort numeric values %new) {
                        my ($asset, $ip ) = split(",",$_);
                $Window->ListView->InsertItem(-text => [ "$asset", "$ip" ]
);
        };
}
sub numeric { $a <=> $b };
sub Radio1_Click {
        if($Window->Radio1->Checked()) {
                $result = "192";
                &MAIN;
        } elsif($Window->Radio2->Checked()) {
                $result = "212.88";
                &MAIN;
        } elsif($Window->Radio3->Checked()) {
                $result = "212.74";
                &MAIN;
        }
}
sub Radio2_Click { Radio1_Click(); }
sub Radio3_Click { Radio1_Click(); }
sub ListView_ColumnClick {
        my $column = shift;
        if ($result ne "" ) {
                if ( $column == 1 ) {&MAIN;}
                if ( $column == 0 ) {&MAIN1;}
        }
       
}
__END__
Regards


Mike Solomon
Technical Manager
Work     01582 831125
Mobile 07941 537 172
email   msolomon@3s-technology.com
============================================================================

======
Important: Any views or opinions expressed by the sender do not necessarily
represent those of the 3s Group. This e-mail and any attachment(s)
are intended for the above named only and may be confidential.  If you are
not
the named recipient please notify us immediately.  You must not copy or
disclose
the contents to any third party.
Internet e-mail is not a fully secure communications medium.  Please take
this into account when sending e-mail to us.
Any attachment(s) to this e-mail are believed to be free from virus, but it
is the responsibility of the recipient to make all the necessary virus
checks.
www.3s-group.com
=========================================================================
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users

_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users