From: Eric H. <Ha...@sw...> - 2002-02-19 22:30:13
|
Peter, I don't think I can help you with any of your problems I'm sorry to = say.=20 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=3D15; $checked=3D$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=3D15; %data =3D $LV->ItemInfo($row,0); $image=3D $data{-image}; # image nbr in image list displayed = at row 15=20 $column1text=3D $data{-text}; # text value in first column of row = 15 =20 %data =3D $LV->ItemInfo($row,1); $column2text=3D $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 =3D> $row, -image =3D> 1); # display 2nd image = in image list Here is a complete declaration of the ListView and its ImageList: EXAMPLE $B1 =3D new Win32::GUI::Bitmap("deselected.bmp"); # off light $B2 =3D new Win32::GUI::Bitmap("selected.bmp"); # on light $IL =3D 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 =3D $W->AddListView( -name =3D> "ListView", -left =3D> 12, -top =3D> 70, -height =3D> 260, -width =3D> 670,=20 ); $LV->View(1); # detailed listing, i.e. columns and rows $LV->SetImageList($IL,1); # enable gridline and checkboxes cabability=20 # fullrowselect defined below, but not activated with SendMessage $LVM_SETEXTENDEDLISTVIEWSTYLE =3D 0x1000 + 54; $LVS_EX_GRIDLINES =3D 0x001; $LVS_EX_FULLROWSELECT =3D 0x020; $LVS_EX_CHECKBOXES =3D 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 =20 ######################## sub ListView_ItemClick { ######################## $row =3D shift; =20 } 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.=20 EXAMPLE $DetailSearchTXT->SetFocus(); $DetailSearchTXT->Select(0,length($DetailSearchTXT->Text())); Regards, Eric Hansen Dallas, Texas USA |