LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get Table rows to be always selected across all columns?

Hello,

I am trying to get a two column table in my GUI to have the behavior where if you click on a cell to select it, both cells belonging to the same row are automaticly selected together. 

I have tried using the function below where PANEL_FILES is the table containing aa two column file list.

SetCtrlAttribute(panelHandle, PANEL_FILES, ATTR_FULL_ROW_SELECT, 1);

It is causing the following error:
    NON-FATAL RUN-TIME ERROR:   "testing.c", line 120, col 5,  thread id 0x0000066C:  
    Library function error (return value == -46 [0xffffffd2]).   The attribute passed is not valid

Can anyone tell me what am I doing wrong and how can I achieve the desired results?

Thanks so much,
Brian

0 Kudos
Message 1 of 5
(3,704 Views)

Hi, you can do the following:

 switch (event) {
  case EVENT_LEFT_CLICK:
  case EVENT_RIGHT_CLICK:
   // Hilight line pointed to by mouse
   GetTableCellFromPoint (panel, control, MakePoint (eventData2, eventData1), &cell);
   if (cell.x == 0 && cell.y == 0) return 1;    // Clicked outside the table (on the label?)
   GetNumTableRows (panel, control, &r);
   SetTableCellRangeAttribute (panel, control, MakeRect (1, 1, r, 6),
        ATTR_TEXT_BOLD, 0);      // Cancel highlight on all table (previous highlighted row)
   SetTableCellRangeAttribute (panel, control, MakeRect (cell.y, 1, 1, 6),
        ATTR_TEXT_BOLD, 1);      // Hilight current row
    break;
}

Instead of TEXT_BOLD you can use any other highlighting method.



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
(3,697 Views)

Hello, 

Please does not work this exemple, can you help me

0 Kudos
Message 3 of 5
(3,140 Views)

What is your exact goal?

It's true that my example does not actually set a table selection: it highlights the row clicked cell belongs to making all cells bold. 

 

To actually select the row you must use 

GetActiveTableCell (panel, control, &cell);
SetTableSelection (panel, control, VAL_TABLE_ROW_RANGE (cell.y));

The reason why I suggested those instructions is that I normally don't like how the selection appears on tables with coloured text and/or background, so I resolved to highlight the row by making the text bold. It's to be said also that I normally don't use cell selection in my programs. If you on the contrary want to leverage on cells being selected or not, SetTableSelection should give you the desired result.



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
(3,124 Views)

Thank you, I found the solution

0 Kudos
Message 5 of 5
(3,114 Views)