LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Tree control column question - Hot/Indicator

Solved!
Go to solution

Is it possible to have some columns in a tree control be hot (edittable), and others as indicators (not edittable)?  It seems as if all the columns (except for the "0th" first column) must be either all hot or all indicators.  I also looked into the Cell attributes and there is no way to make indiviidual cells as either hot or indicators either (like Table controls).

 

I did notice that items can be dimmed using tho ATTR_CELL_DIMMED attribute, which gives a behaviour similar to what I'm looking for (user can't edit the cell value) but also gives the cell a greyed out appearance.  I tried manually setting the appearance of the cell back to what I would like (ie ATTR_LABEL_TEXT to black) but naturally this didn't have an effect.  Any ideas?  Thanks.

0 Kudos
Message 1 of 7
(3,944 Views)
Solution
Accepted by topic author tstanley

You can pick and choose which columns and cells you'd like to edit using the tree's callback function if you have CVI 2009 or later. You can use ATTR_TREE_RUN_STATE and ATTR_TREE_EDITABLECELLS inside EVENT_LEFT_CLICK (and probably EVENT_LEFT_DOUBLE_CLICK too) to accomplish this. I'm attaching a simple project with a tree that you can edit the first column with a double click, the 2nd column with a single click and you can't change the data in the 3rd column at all. You could even specify individual cells you to make editable if that's what you wanted to do.

 

Kevin B.
Message 2 of 7
(3,930 Views)

Nifty.  Didn't think of using the callbacks in that way, but it does exactly what I was looking for.  Thanks!

0 Kudos
Message 3 of 7
(3,928 Views)

An easier way to prevent certain cells from being edited is to swallow the EVENT_BEGIN_EDIT_TREE_CELL event for a particular cell.

 

You can replace the TreeCB in Kevin's TreeColumnEditing.c with this and it'll behave the same way...

 

int CVICALLBACK TreeCB (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    int     swallow = 0;
    int     col;
    switch (event)
        {
        case EVENT_BEGIN_EDIT_TREE_CELL:
            col = eventData2;
            if (col == 2)
                swallow = 1;
            break;
        }
    return swallow;
}

Message 4 of 7
(3,883 Views)

Ah, that works too and is simplier to understand.  Kudos.

0 Kudos
Message 5 of 7
(3,875 Views)

hello, i have the same problem to fill my second column inside a tree... it complains "the index passed out of range"

i dont want use TreeCB... i make a tree column inside a callback function and edit them, no problem with the first column, but it doenst recognize the second column... by which attribute should it make the second column editable? i appreciate your help... my email address is orbit@live.se

SetTreeCellAttribute (panelHandle, PANEL_TREE, VAL_ALL_OBJECTS, 1, ATTR_CELL_TYPE, VAL_CELL_STRING);
//SetTreeColumnAttribute (panelHandle, PANEL_TREE, 1, ATTR_TREE_EDITABLECELLS, 1);
InsertTreeItem (panelHandle, PANEL_TREE, VAL_SIBLING, 1, VAL_LAST, sy, NULL, NULL, xn[i]);

it doesnt recognize ATTR_TREE_EDITABLECELLS, even i have version 2017.. thanks

0 Kudos
Message 6 of 7
(2,659 Views)

Hello Venusnajad,

 

I noticed that in the example Kevin provided (which works fine on my system) uses "ATTR_TREE_EDITABLE_CELLS" whereas in your post, you used "ATTR_TREE_EDITABLECELLS"

Check to see if you have an _ between EDITABLE_CELLS in your program.

 

Hope that helps!

ZK
Technical Support Engineer | NI | Not actually retired but I don't know how to change that
0 Kudos
Message 7 of 7
(2,645 Views)