LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Get the full-row selected item

I have a tree-control with several items. I have the option "Full Row Select" enabled in the advanced tree options. Is it possible to get the index of the item which is full row selected, that means which background is dark blue? I don't want to use the "GetCtrlIndex"-Function cause it returns the index of the item which is active (also possible with no dark-blue background).
0 Kudos
Message 1 of 2
(2,929 Views)
Your tree has ATTR_SELECTION_MODE set to VAL_SELECTION_MULTIPLE (which is the default setting). If you want to allow the user to select multiple items (or no items, as you pointed out) and you need to programmatically find all the selected items, then use GetTreeItem. An example is provided below.

However, if you want the user to select exactly one item, then change the ATTR_SELECTION_MODE to VAL_SELECTION_SINGLE, and then you can use GetCtrlIndex (or GetActiveTreeItem) to find the one item that is selected. In this case, the active item is always the only one that is selected.

To find all the selected items when ATTR_SELECTION_MODE is VAL_SELECTION_MULTIPLE, use GetTreeItem in a loop.

int GetSelectedTreeItems (int panel, int tree)
{
int curItem, numSelected,
direction;

curItem = VAL_FIRST;
direction = VAL_NEXT_PLUS_SELF;
numSelected = 0;
while (1)
{
GetTreeItem (panel, tree, VAL_ALL, 0, curItem, direction, VAL_SELECTED, &curItem);
if (curItem < 0)
break;
numSelected++;
direction = VAL_NEXT;
}
return numSelected;
}
0 Kudos
Message 2 of 2
(2,929 Views)