NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Active Participant
tstanley
Posts: 295
0 Kudos
Accepted Solution

Tree control column question - Hot/Indicator

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.

Member
Kevin_B.
Posts: 58

Re: Tree control column question - Hot/Indicator

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.
National Instruments
Active Participant
tstanley
Posts: 295
0 Kudos

Re: Tree control column question - Hot/Indicator

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

Member
jared
Posts: 156

Re: Tree control column question - Hot/Indicator

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;
}

Active Participant
tstanley
Posts: 295
0 Kudos

Re: Tree control column question - Hot/Indicator

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

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page