LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Begginer - Tree - ATTR_SELECTION_MODE

I want to prohibit the user choose only one item per time in a selection Tree.

In order to do that, i wrote the following code:

void setCustomizeParameterPanelOptions (int parameterHandle, int parameterTree) {

    SetCtrlAttribute(parameterHandle, parameterTree, ATTR_ENABLE_DRAG_DROP, 0);

    SetCtrlAttribute(parameterHandle, parameterTree, ATTR_SHOW_MARKS, 1);
   
    SetCtrlAttribute(parameterHandle, parameterTree, ATTR_SELECTION_MODE, VAL_SELECTION_SINGLE);
}

The problem is that even if I set the attr_selection_mode to val_selection_single, the interface allows the user chooses as many parameters as he wants.

Could someone help me?

Thank you in advance.
0 Kudos
Message 1 of 2
(2,861 Views)

The selection mode has nothing to do with the check boxes or radio buttons that appear next to each tree item when you enable ATTR_SHOW_MARKS. The selection mode determines how many items can be selected, ie. hilited with the blue background using shift+click or shift+arrow keys.

What you want is to restrict how many items are 'marked' using either the check boxes or radio buttons. Changing the ATTR_MARK_TYPE of all the items to VAL_MARK_RADIO is the easiest way make sure at most only one item is marked. To do this, you could either change the default for new items before you populate the tree:

SetTreeItemAttribute(panel, tree, VAL_DFLT_FOR_NEW_OBJECTS, ATTR_MARK_TYPE, VAL_MARK_RADIO);

Or you can set the attribute for all the items in an already populated tree like this:

SetTreeItemAttribute(panel, tree, VAL_ALL_OBJECTS, ATTR_MARK_TYPE, VAL_MARK_RADIO);

I hope this helps.

- jared

 

0 Kudos
Message 2 of 2
(2,858 Views)