LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

example of table

Hi,

 

I'm new to CVI and having problems with creating the callback code that will respond to clicking and changing the value in a table cell. The callbacks need to determine which cell was modified and what the mod was and then take some action.

 

Do any of you have code examples that you can share that perform this type of function.

 

Thanks

 

 

0 Kudos
Message 1 of 5
(4,046 Views)

I am afraid that there is no simple answer to your question.

The easy part is determining the active cell the user is operating on: when handling EVENT_VAL_CHANGED event the table callback receives active cell coordinates in eventData parameters, as explained in the event description in the online help. Additionally, the table callback can respond to EVENT_ACTIVE_CELL_CHANGE which is fired when theuser moves on the table either with the keyboard or mouse.

 

The most complicated thing is determining what the modification was: since the different types of cell types the table can handle, every one of them will need some particular code to handle the modification, unless you can take a in-memory copy of the tablecontents and operate only on commit events by comparing new and old contents of the modified cell.

Message Edited by Roberto Bozzolo on 03-30-2009 10:17 AM


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(4,035 Views)

Thanks Roberto.

I'm attaching two slides showing the table snippet so all can see what I'm trying to deal with.

As shown on the first slide,  I need to collect all the current data in the table, form a message and send it out the serial port. I also need to take serial port data and populate the "value" column. I think I know how to deal with the serial port.

 

One the second slide, I'm showing another requirement. If any of the cells on the A/D column change to "A", all the cells above it must also change to "A". I'd like to automate that change.

 

Thanks,

daf

0 Kudos
Message 3 of 5
(4,019 Views)

Ok, now it's more clear.

 

On the first item, collecting a series of integer values out of the table can be done with GetTableCellRangeVals (consider the use of the built-in macro VAL_TABLE_COLUMN_RANGE to select the entire column without need to go into the pain of MakeRect Smiley Wink ). Symmetrically, SetTableCellRangeVals can be used to put the values received from the serial port on the table column.

 

As per the second item, you can use a set of function to determine the value and / or the index of the cell selected on value change event; here a sample code that shows all relevant data of a cell on this event:

 

    int        idx;
    char    a[5], msg[512];
    Point cell;

    switch (event) {
        case EVENT_VAL_CHANGED:
            cell.y = eventData1;
            cell.x = eventData2;
            GetTableCellVal (panelHandle, PANEL_TABLE, MakePoint (cell.x, cell.y), a);
            GetTableCellRingIndexFromValue (panelHandle, PANEL_TABLE, 0, MakePoint (cell.x, cell.y), &idx, a);
            sprintf (msg, "EVENT_VAL_CHANGED: ActiveCell is (col, row) %d, %d - value %s - index %d", cell.x, cell.y, a, idx);
            MessagePopup ("Cell event", msg);
            break;
    }
 

In this case, since  the value to set is the same for all cells you can use FillTableCellRange () instruction.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 5
(4,008 Views)

Thanks Roberto!

I'll will try these suggestions later in the week,

daf

0 Kudos
Message 5 of 5
(4,002 Views)