From: Thomas, T. B <tim...@lm...> - 2001-02-15 17:51:55
|
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) { =09 %data=3D$ListView->ItemInfo(($ListView->SelectedItems)[$i]); $filename=3D$data{-text}; ... ------------------------------------------------------------------------= ---- --------------------- Tim Thomas Unix Systems Administrator Lockheed Martin EIS =B7 Denver Data Center 303-430-2281 mailto:tim...@lm... ------------------------------------------------------------------------= ---- --------------------- -----Original Message----- From: Michael Solomon [mailto:MSo...@3s...] Sent: Thursday, February 15, 2001 10:32 AM To: 'per...@li...' Subject: RE: [perl-win32-gui-users] get value from list Tim,=20 Thanks for this=20 Unfortunately this gets all the items from the list=20 What I want to do is to click on an item in the list and just capture = that=20 For example=20 If I have a list showing=20 1=20 2=20 3=20 if I click on the 3, I want to capture 3=20 I hope this makes sense=20 Regards=20 Mike Solomon=20 Technical Manager=20 Work 01582 831125=20 Mobile 07941 537 172=20 email mso...@3s...=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=20 Important: Any views or opinions expressed by the sender do not = necessarily=20 represent those of the 3s Group. This e-mail and any attachment(s)=20 are intended for the above named only and may be confidential. If you = are not=20 the named recipient please notify us immediately. You must not copy or disclose=20 the contents to any third party.=20 Internet e-mail is not a fully secure communications medium. Please = take=20 this into account when sending e-mail to us.=20 Any attachment(s) to this e-mail are believed to be free from virus, = but it=20 is the responsibility of the recipient to make all the necessary virus=20 checks.=20 www.3s-group.com=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=20 -----Original Message-----=20 From: Thomas, Timothy B [mailto:tim...@lm...]=20 Sent: 15 February 2001 16:48=20 To: 'per...@li...'=20 Subject: RE: [perl-win32-gui-users] get value from list=20 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,=20 or you can search the archives.=20 Here's a piece of code I just wrote that gets all the data, including = the=20 image, from a listview, it puts it into a hash.=20 I used this with the column sort routine that has been floating around, = by=20 Jonathan Southwick [jso...@al...]. I am still working out the = bugs, but this section of code should help you.=20 # you must already have $totalcols (the # of columns in your=20 listview)=20 # I don't think there is a way to pull this from the = object.=20 %data=3D();=20 $rows=3D$ListView->Count();=20 for $i(0..$rows-1)=20 {=20 $row=3D"";=20 my %result=3D$ListView->GetItem($i,0);=20 $image=3D$result{-image};=20 for $j(0..$totalcols-1)=20 {=20 my %result=3D$ListView->GetItem($i,$j);=20 $text=3D$result{-text};=20 $row.=3D",$text";=20 }=20 $data{$i}=3D"$image$row";=20 #Win32::MsgBox("data($i)=3D$image$row\n");=20 }=20 ------------------------------------------------------------------------= ---- ---------------------=20 Tim Thomas=20 Unix Systems Administrator=20 Lockheed Martin EIS =B7 Denver Data Center=20 303-430-2281=20 mailto:tim...@lm...=20 ------------------------------------------------------------------------= ---- ---------------------=20 -----Original Message-----=20 From: Michael Solomon [mailto:MSo...@3s...]=20 Sent: Thursday, February 15, 2001 5:19 AM=20 To: Perl Gui (E-mail)=20 Subject: [perl-win32-gui-users] get value from list=20 I am querying a database and putting the output into a listview=20 What I would like to next is to click on an item in the list and then=20 drilldown into the data base=20 The question is how can I return the value from a List=20 I am fairly new at using Win32::GUI and apologise if this is a stupid=20 question.=20 Should I be using a different type than listview and if so what should = I be=20 using?=20 use strict;=20 use Socket;=20 use Win32::GUI;=20 use Win32::ODBC;=20 #set variables=20 my (%Data, %new, $result, $Window, $width);=20 my $Dir =3D "//neptune/tech_dept/databases";=20 my $DBase =3D "asset.mdb";=20 my $DriverType =3D "Microsoft Access Driver (*.mdb)";=20 my $Desc =3D "Description=3DThe Win32::ODBC Test DSN for = Perl";=20 my $DSN =3D "tmpdsn";=20 $Window =3D new GUI::Window(=20 -name =3D> "Window",=20 -text =3D> "Win32::GUI::ListView test",=20 -width =3D> 350,=20 -height =3D> 500,=20 -left =3D> 100,=20 -top =3D> 100,=20 );=20 $Window->AddListView(=20 -name =3D> "ListView",=20 -left =3D> 10,=20 -top =3D> 10,=20 -width =3D> 330,=20 -height =3D> 383,=20 -style =3D> WS_VISIBLE | 1,=20 -gridlines =3D> 1,=20 );=20 $width =3D $Window->ListView->ScaleWidth;=20 $Window->ListView->InsertColumn(=20 -index =3D> 0,=20 -width =3D> $width/2,=20 -text =3D> "Asset No",=20 );=20 $Window->ListView->InsertColumn(=20 -index =3D> 1,=20 -width =3D> $width/2,=20 -text =3D> "IP Address",=20 );=20 $Window->AddRadioButton(=20 -name =3D> "Radio1",=20 -left =3D> 8,=20 -top =3D> 410,=20 -text =3D> "192 Network ",=20 -tabstop =3D> 1,=20 );=20 $Window->AddRadioButton(=20 -name =3D> "Radio2",=20 -left =3D> 8,=20 -top =3D> 430,=20 -text =3D> "212 XTML ",=20 -tabstop =3D> 1,=20 );=20 $Window->AddRadioButton(=20 -name =3D> "Radio3",=20 -left =3D> 8,=20 -top =3D> 450,=20 -text =3D> "212 EasyNet ",=20 -tabstop =3D> 1,=20 );=20 #$Window->ListView->TextColor(hex("0000FF"));=20 $Window->Show();=20 $Window->Dialog();=20 sub MAIN {=20 #set up dsn=20 Win32::ODBC::ConfigDSN(ODBC_ADD_DSN, $DriverType, = ("DSN=3D$DSN",=20 "Description=3DThe Win32 ODBC Test DSN for Perl", "DBQ=3D$Dir\\$DBase", = "DEFAULTDIR=3D$Dir", "UID=3D", "PWD=3D"));=20 #open connection as $0=20 my $cO =3D new Win32::ODBC($DSN);=20 #run sql=20 $cO->Sql("SELECT assetid, ipaddress FROM ip_address where = ipaddress=20 like '${result}%'");=20 #reset new=20 %new =3D ();=20 # Fetch the next rowset=20 while($cO->FetchRow()){=20 %Data =3D $cO->DataHash();=20 #convert to binary=20 $new{inet_aton($Data{ipaddress})} =3D=20 "$Data{assetid},$Data{ipaddress}";=20 }=20 #close database=20 $cO->Close();=20 #remove tempdsn=20 Win32::ODBC::ConfigDSN(ODBC_REMOVE_DSN, $DriverType, = "DSN=3D$DSN");=20 #clear items=20 $Window->ListView->Clear(); =20 foreach (sort keys %new) {=20 my ($asset, $ip ) =3D split(",",$new{$_});=20 $Window->ListView->InsertItem(-text =3D> [ "$asset", = "$ip" ]=20 );=20 };=20 }=20 sub MAIN1 {=20 #clear items=20 $Window->ListView->Clear(); =20 foreach (sort numeric values %new) {=20 my ($asset, $ip ) =3D split(",",$_);=20 $Window->ListView->InsertItem(-text =3D> [ "$asset", = "$ip" ]=20 );=20 };=20 }=20 sub numeric { $a <=3D> $b };=20 sub Radio1_Click {=20 if($Window->Radio1->Checked()) {=20 $result =3D "192";=20 &MAIN;=20 } elsif($Window->Radio2->Checked()) {=20 $result =3D "212.88";=20 &MAIN;=20 } elsif($Window->Radio3->Checked()) {=20 $result =3D "212.74";=20 &MAIN;=20 }=20 }=20 sub Radio2_Click { Radio1_Click(); }=20 sub Radio3_Click { Radio1_Click(); }=20 sub ListView_ColumnClick {=20 my $column =3D shift;=20 if ($result ne "" ) {=20 if ( $column =3D=3D 1 ) {&MAIN;}=20 if ( $column =3D=3D 0 ) {&MAIN1;}=20 }=20 =20 }=20 __END__=20 Regards=20 Mike Solomon=20 Technical Manager=20 Work 01582 831125=20 Mobile 07941 537 172=20 email mso...@3s...=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=20 Important: Any views or opinions expressed by the sender do not = necessarily=20 represent those of the 3s Group. This e-mail and any attachment(s)=20 are intended for the above named only and may be confidential. If you = are=20 not=20 the named recipient please notify us immediately. You must not copy or = disclose=20 the contents to any third party.=20 Internet e-mail is not a fully secure communications medium. Please = take=20 this into account when sending e-mail to us.=20 Any attachment(s) to this e-mail are believed to be free from virus, = but it=20 is the responsibility of the recipient to make all the necessary virus=20 checks.=20 www.3s-group.com=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=20 _______________________________________________=20 Perl-Win32-GUI-Users mailing list=20 Per...@li...=20 http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users=20 |