User Tools

Site Tools


finding_20which_20items_20are_20selected_20in_20a_20list_20view

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

finding_20which_20items_20are_20selected_20in_20a_20list_20view [2018/03/31 13:19]
127.0.0.1 external edit
finding_20which_20items_20are_20selected_20in_20a_20list_20view [2018/04/15 19:14] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //by Richard Russell, September 2010//\\ \\  A significant difference between a **List View** and a **List Box** is that the former allows you to select **multiple** items whereas the latter only allows you to select a **single** item. This complicates somewhat the issue of discovering which item(s) is/are selected.\\ \\  With a **List Box** you can simply send the **LB_GETCURSEL** message:​\\ ​ //by Richard Russell, September 2010//\\ \\  A significant difference between a **List View** and a **List Box** is that the former allows you to select **multiple** items whereas the latter only allows you to select a **single** item. This complicates somewhat the issue of discovering which item(s) is/are selected.\\ \\  With a **List Box** you can simply send the **LB_GETCURSEL** message:​\\ ​
 +<code bb4w>
         SYS "​SendMessage",​ hListBox%, LB_GETCURSEL,​ 0, 0 TO sel%         SYS "​SendMessage",​ hListBox%, LB_GETCURSEL,​ 0, 0 TO sel%
 +</​code>​
 where **sel%** is set to the index of the current selection (or -1 if no item is selected).\\ \\  With a **List View** you can optionally discover how many items are selected as follows:​\\ ​ where **sel%** is set to the index of the current selection (or -1 if no item is selected).\\ \\  With a **List View** you can optionally discover how many items are selected as follows:​\\ ​
 +<code bb4w>
         SYS "​SendMessage",​ hListView%, LVM_GETSELECTEDCOUNT,​ 0, 0 TO nsel%         SYS "​SendMessage",​ hListView%, LVM_GETSELECTEDCOUNT,​ 0, 0 TO nsel%
 +</​code>​
 where **nsel%** is set to the number of selected items.\\ \\  To find which item(s) is/are selected you can send the List View the **LVM_GETNEXTITEM** message:​\\ ​ where **nsel%** is set to the number of selected items.\\ \\  To find which item(s) is/are selected you can send the List View the **LVM_GETNEXTITEM** message:​\\ ​
 +<code bb4w>
         iStart% = -1         iStart% = -1
         SYS "​SendMessage",​ hListView%, LVM_GETNEXTITEM,​ iStart%, LVNI_SELECTED TO index%         SYS "​SendMessage",​ hListView%, LVM_GETNEXTITEM,​ iStart%, LVNI_SELECTED TO index%
 +</​code>​
 where **index%** is set to the index of the first item selected (or to -1 if no items are selected).\\ \\  To discover which other items (if any) are selected send the message repeatedly with **iStart%** set to the index previously returned, until **index%** is -1:\\  where **index%** is set to the index of the first item selected (or to -1 if no items are selected).\\ \\  To discover which other items (if any) are selected send the message repeatedly with **iStart%** set to the index previously returned, until **index%** is -1:\\ 
 +<code bb4w>
         iStart% = -1         iStart% = -1
         REPEAT         REPEAT
Line 15: Line 22:
           iStart% = index%           iStart% = index%
         UNTIL index% = -1         UNTIL index% = -1
 +</​code>​
 Use the **Windows Constants** [[/​Tools%20and%20Utilities|utility]] or **API Viewer** to discover the values of the constants. Use the **Windows Constants** [[/​Tools%20and%20Utilities|utility]] or **API Viewer** to discover the values of the constants.
finding_20which_20items_20are_20selected_20in_20a_20list_20view.txt ยท Last modified: 2018/04/15 19:14 by tbest3112