LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

I can't use the SetTableRowAttribute function.

Hi.
I made a program using the table related function. But I couldn't use the SetTableRowAttribute function in my program.
What's the problem ?.
Please check it and let me know it.
Thank you.
---------------------------------------------
#include
#include "tabletest.h"
#include

static int panelHandle;

int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "\\jangwork\\test2\\tabletest.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}

int CVICALLBACK tabletestfunc (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
Point Cell;
int NumOfColumn;
int numRows;
int rowNum;

switch (event)
{
case EVENT_LEFT_CLICK:
GetNumTableRows (panel, control, &numRows);
for (rowNum = 1; rowNum <= numRows; rowNum++)
{
if (rowNum % 2)
{

SetTableCellRangeAttribute (panel, control,
VAL_TABLE_ROW_RANGE(rowNum),
ATTR_TEXT_BGCOLOR,0x999966L);
}
else
{
SetTableCellRangeAttribute (panel, control,
VAL_TABLE_ROW_RANGE(rowNum),
ATTR_TEXT_BGCOLOR,0xCCCC99L);
}
}
SetTableCellVal(panel,control,MakePoint(1,1),1);
GetTableCellFromPoint (panelHandle, PANEL_TABLE_DEFECTS,
MakePoint(eventData2, eventData1), &Cell);
printf(" PanelCoordX=%d PanelCoordY=%d Cell of X=%d Y=%d\n",eventData2,eventData1,Cell.x,Cell.y);
SetCtrlVal (panelHandle, PANEL_NUM_COLUMN, Cell.x);
SetCtrlVal (panelHandle, PANEL_NUM_ROW, Cell.y);
GetNumTableColumns (panel, control, &NumOfColumn);
SetTableCellRangeAttribute(panel, control, MakeRect(Cell.y, 1, 1, NumOfColumn), ATTR_TEXT_BGCOLOR,VAL_RED); // It works well.
// SetTableRowAttribute(panelHandle, PANEL_TABLE_DEFECTS, Cell.y, ATTR_TEXT_BGCOLOR,VAL_RED); // It doesn't work. Why ?????????
break;
}
return 0;
}

int CVICALLBACK Quit (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}
0 Kudos
Message 1 of 3
(3,403 Views)
I think this is the fault of a common misconception about the Row and Column attribute functions. They DO NOT effect existing cells. Using SetTableRowAttribute on cell attributes sets the default value of the attribute for any FUTURE cells created in that row. You need to use SetTableRangeAttribute with a range that includes that row to effect existing cells.

Best Regards,

Chris Matthews
Measurement Studio Support Manager
0 Kudos
Message 2 of 3
(3,403 Views)

to be corrected: SetTableCellRangeAttribute()

 

0 Kudos
Message 3 of 3
(3,076 Views)