Peter, I don't think I can help you with any of your problems I'm sorry to say.
I'm especially sorry not to be able to help you with initially setting
checkboxes within a ListView. Don't know how to do that. Was not something my
app needed to do, but I can see how it would be useful. I can share a couple
things I do know howver that might be of interest to you or someone else:
Peter, you already know that you can get the value of the checkbox state for a
row in the ListView using
EXAMPLE
$row=15;
$checked=$LV->ItemCheck($row); # checkbox state is 0 or 1.
This is documented.
But, what is not documented is how to get the value of other properties within
the ListView such as -text and -image
EXAMPLE
$row=15;
%data = $LV->ItemInfo($row,0);
$image= $data{-image}; # image nbr in image list displayed at row
15
$column1text= $data{-text}; # text value in first column of row 15
%data = $LV->ItemInfo($row,1);
$column2text= $data{-text}; # text value in 2nd column of row 15
You can change the value of a property associated with a row of the ListView by
EXAMPLE
$LV->ChangeItem(-item => $row, -image => 1); # display 2nd image in image
list
Here is a complete declaration of the ListView and its ImageList:
EXAMPLE
$B1 = new Win32::GUI::Bitmap("deselected.bmp"); # off light
$B2 = new Win32::GUI::Bitmap("selected.bmp"); # on light
$IL = new Win32::GUI::ImageList(16, 16, 0, 2, 10);
$IL->Add($B1, 0); # image 0 or first image in list
$IL->Add($B2, 0); # image 1 or 2nd image in list
$LV = $W->AddListView(
-name => "ListView",
-left => 12,
-top => 70,
-height => 260,
-width => 670,
);
$LV->View(1); # detailed listing, i.e. columns and rows
$LV->SetImageList($IL,1);
# enable gridline and checkboxes cabability
# fullrowselect defined below, but not activated with SendMessage
$LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1000 + 54;
$LVS_EX_GRIDLINES = 0x001;
$LVS_EX_FULLROWSELECT = 0x020;
$LVS_EX_CHECKBOXES = 0x004;
$LV->SendMessage($LVM_SETEXTENDEDLISTVIEWSTYLE, 0,
$LVS_EX_GRIDLINES | $LVS_EX_CHECKBOXES,
);
HOW DO YOU KNOW WHAT ROW IN THE LISTVIEW HAS BEEN SELECTED BY THE USER???
EXAMPLE
########################
sub ListView_ItemClick {
########################
$row = shift;
}
Off the subject a little, here is a little trick that is useful to someone
wanting to initially set focus on a text box and have the data highlighted in
replace/overwrite mode.
EXAMPLE
$DetailSearchTXT->SetFocus();
$DetailSearchTXT->Select(0,length($DetailSearchTXT->Text()));
Regards,
Eric Hansen
Dallas, Texas USA