LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Check Box in a Table

Is it possible to place a check box into a cell within a table control?
0 Kudos
Message 1 of 7
(7,916 Views)
Yes, sort of. Make the cell a picture cell (ATTR_CELL_TYPE = VAL_CELL_PICTURE) and then give it an image that looks like a checkbox (you can obtain one by calling GetCtrlDisplayBitmap on a checkbox control).

You will then need to toggle the 'on' and 'off' images whenever you receive a left click event on the cell.

Luis
NI
Message 2 of 7
(7,916 Views)

Could I get an example on this? I could not find/get the check box picture in the table by the callback listed in the reply.

 

Thanks

ChipB

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

ChipB, if you are using latest cvi versions you can benefit from new cell types that were introduced in version 8, specifically ring cell type: as an alternative to a checkbox you could create two items labelled Yes and No in a ring cell. in the table callback you will retrieve the cell value on a COMMIT event as a string and discriminate on it.

Regarding Luis suggestion, you must have a checkbox elsewere in the panel, retrieve its bitmap with GetCtrlBitmap (panel, control, 0, &bitmap); (well, two bitmaps, corresponding to checked / unchecked values; the bitmap can next be discarded) and load one of them as an image in a table cell of picture type: in the callback for table you will need to update the cell picture depending on previously loaded one. Consider that a cell can hold values for different types regardless the type shown: you can show a picture in a cell but contemporarily hold a integer value 0 or 1 corresponding to the "checkbox" value shown. in the callback function you can manipulate both the picture and the value associated to the cell.



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?
Message 4 of 7
(7,594 Views)

Here is a simple program that shows how to easily put a check box in a table cell.

http://forums.ni.com/ni/board/message?board.id=180&message.id=13287#M13287

Message 5 of 7
(7,581 Views)

Ok, I got the check box to change state... but getting a 1 or 0 returned escapes me... I have a table of measurements and the checked measurements I want to put into an array to do a linear extrapolation on... but when I roll through the row 1 column(count) to find the "checked" items, I don't get a returned value. what is the reason? same program used just build a on/off array

 

ChipB

0 Kudos
Message 6 of 7
(7,326 Views)

In the tableCheck example program (from the link in my previous post), check out the function ToggleTableCellCheck. It is storing the 1 or 0 (or whether the checkbox is checked or not) in the numeric value of the table cell. You could make a function like this to return the check state of a table cell.

 

/* returns 1 if the cell is checked, 0 if the cell is unchecked */

int GetCellCheckedState(int panel, int table, Point cell)
{
 int val;
 SetTableCellAttribute(panel, table, cell, ATTR_CELL_TYPE, VAL_CELL_NUMERIC);
 GetTableCellVal(panel, table, cell, &val);
 SetTableCellAttribute(panel, table, cell, ATTR_CELL_TYPE, VAL_CELL_PICTURE);
 return val;
}

I hope this helps.

 

- jared

Message 7 of 7
(7,300 Views)