#-- This is a code snipet from a Dual Listbox control dialog which
allows
#-- the user to reorder the columns of a ListView "on-the-fly". The
order
#-- of columns saved is saved in a MS-ACCESS table for each unique
username
#-- so that the user will retain those column order settings for future
#-- sessions.
#--
#-- BUG REPORT:
#-- I am noticing column 0 of the Listview is much wider than the
#-- width of the column header text? This appears to be a bug in the
#-- widget. See code below for setting column widths.
#####################
sub BTN_Save4_Click {
#####################
my $ls_text; #-- local scalar
my $ls_sel;
my $ls_i;
my $ls_sqltxt;
my $ls_ret;
my $ls_error;
my $ls_len;
#-- if all column names have not been selected from left listbox,
return.
if ($LB_List1->Count() > 0) {return 1;}
@ga_ColumnOrder=();
%gh_ColumnOrder=();
%gh_ColumnList=();
$ls_sqltxt = "UPDATE tblColumnOrder SET ";
for ($ls_sel=0;$ls_sel<=36;$ls_sel++) {
$ls_text=$LB_List2->GetString($ls_sel);
$gh_ColumnOrder{$ls_sel}=$ls_text;
$gh_ColumnList{$ls_text}=$ls_sel;
$ga_ColumnOrder[$ls_sel]=$gh_OrigColumnList{$ls_text};
$ls_sqltxt = $ls_sqltxt . "[" . $ls_text . "]=" . $ls_sel . ",";
}
$LV->SetColumnOrderArray(@ga_ColumnOrder);
$LV->RedrawItems(0,$LV->Count()-1);
for($ls_i=0;$ls_i<=36;$ls_i++) {
$LV->SetColumnWidth($ls_i,-2); #-- adjust to fit column header
text
}
#-- for some reason, column 0 stretches out wide way! past the width
of
#-- the column header text? All other columns are as wide as header
#-- text. This appears to be a bug in the widget.
$ls_len=length($ls_sqltxt);
$ls_sqltxt=substr($ls_sqltxt,0,($ls_len-1));
$ls_sqltxt=$ls_sqltxt . " WHERE username = '" . $gs_LoggedUser . "'";
...
}