03-04-2011 08:55 AM
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.
Solved! Go to Solution.
03-04-2011 03:01 PM
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.
03-07-2011 11:33 AM
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;
col = eventData2;
if (col == 2)
swallow = 1;