Sure:
use strict; use warnings; use Win32::GUI(); use DBI; my $mw = Win32::GUI::Window->new( -text => "ListView", -size => [ 500, 500 ], -pos => [ 200, 200 ], ); sub mw_Terminate { return -1 } my $lv = $mw->AddListView( -name => "view", -pos => [ 20, 20 ], -size => [ 400, 400 ], -gridlines => 1 ); $lv->InsertColumn( -item => 0, -text => "PID", -width => 50); $lv->InsertColumn( -item => 1, -text => "Name", -width => 100); $lv->InsertColumn( -item => 2, -text => "Address", -width => 100); $lv->InsertColumn( -item => 3, -text => "Salary", -width => 100); my $dbfile = 'C:/code/lqs.db'; my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","",""); my $stmt = qq(select id,name,address,salary from deliver order by sala +ry desc); my $sth = $dbh->prepare($stmt); $sth->execute; while(my @row = $sth->fetchrow_array()){ $lv->InsertItem(-text => [$row[0],$row[1],$row[2],$row[3]]); } $mw->Show; Win32::GUI::Dialog(); sub view_ColumnClick{ my $var = shift; $lv->DeleteAllItems; if($var == 0){ $stmt = qq(select id,name,address,salary from deliver order by + id asc); $sth = $dbh->prepare($stmt); $sth->execute; while(my @row = $sth->fetchrow_array()){ $lv->InsertItem(-text => [$row[0],$row[1],$row[2],$row[3]] +); } } elsif($var==1){ $stmt = qq(select id,name,address,salary from deliver order by + name asc); $sth = $dbh->prepare($stmt); $sth->execute; while(my @row = $sth->fetchrow_array()){ $lv->InsertItem(-text => [$row[0],$row[1],$row[2],$row[3]] +); } } elsif($var==2){ $stmt = qq(select id,name,address,salary from deliver order by + address asc); $sth = $dbh->prepare($stmt); $sth->execute; while(my @row = $sth->fetchrow_array()){ $lv->InsertItem(-text => [$row[0],$row[1],$row[2],$row[3]] +); } } elsif($var==3){ $stmt = qq(select id,name,address,salary from deliver order by + salary asc); $sth = $dbh->prepare($stmt); $sth->execute; while(my @row = $sth->fetchrow_array()){ $lv->InsertItem(-text => [$row[0],$row[1],$row[2],$row[3]] +); } } }
Any comments are welcome.
In reply to Re: Win32::Gui listview column click
by Anonymous Monk
in thread Win32::Gui listview column click
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |