LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

From listbox -- how to retrieve itemindex

hi
can u suggest me how to get index of a item selected ...
actually i am using a listbox with checkbox...want to get the
 item index of the selected item when we click it..
 
 
0 Kudos
Message 1 of 9
(4,870 Views)

GetCtrlVal(panel, control, void *val) will return the actual "value" of the item selected.

GetCtrlIndex(pane, control, int *val) will the zero-based number that the selected item is within the list.

 

GetValuefromIndex, getindexfromValue, and getlabelfromiIndex  are all functions that will convert these data into other relevant data.

0 Kudos
Message 2 of 9
(4,869 Views)

thanks scomack..i tried all those control functions...

but what i require is... consider when we move around a listbox with checkmark option,

i want to highlight the item which i clicked..so can u suggest me the best to do this..

 

 

0 Kudos
Message 3 of 9
(4,859 Views)

Hello,

could you explain exactly what you would like to do? When you click a List item, the item will be highlighted automatically. There is no need to program this.

If you want to know which List item is clicked, you can get the index from the function GetIndexFromPoint. The mouse coordinates are stored in the callback function parameters evenData1 (y) and eventData2 (x) when the parameter event equals EVENT_LEFT_CLICK.

0 Kudos
Message 4 of 9
(4,855 Views)
thanks Wim
actually iam using a Listbox with checkbox in hot control mode...
i want to get the item which i click ..i tried the EVENT_COMMIT to catch it but cant..
when we click an item in listbox it never gets changed that is it gets changed only
 when we click the checkbox ..so i want to get the itemindex which i click in the listbox..
can u suggest me the best to do this...
0 Kudos
Message 5 of 9
(4,850 Views)

Hello,

if I understand the problem correct, this is what you should do: Edit the List Box by double clicking it in the UIR editor. Click the List Box Options button and enable the check box 'Text Click Toggles Check'. Now, when you click an item in the List Box, the action is the same as when you would have clicked the item's checkbox.

0 Kudos
Message 6 of 9
(4,845 Views)

sorry wim u misunderstand my pblm...

what i need is i dont want to make the listbox item state changed when i click listbox item name..

so i edit the lisbox option, disable the option text clicks toogle checkmark already..

what i need is if i click the listbox item text it shouldnt change its state..

but i want the item index of the lisbox item. when i click it ....

waiting for ur reply

sks

0 Kudos
Message 7 of 9
(4,843 Views)

Hello sks,

If you just want the index of the clicked item, why not using my previous suggestion:

If you want to know which List item is clicked, you can get the index from the function GetIndexFromPoint. The mouse coordinates are stored in the callback function parameters evenData1 (y) and eventData2 (x) when the parameter event equals EVENT_LEFT_CLICK.

Your callback function should look like this:


int CVICALLBACK ListBoxCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) {
 int index;
 
 switch (event) {
  case EVENT_LEFT_CLICK:
   
   GetIndexFromPoint(pnl, PNL_LISTBOX, MakePoint (eventData2, eventData1), &index, 0, 0);
   
   DebugPrintf ("Index: %i\n", index);
   
   // Do whatever you want to do with the list item...
   
   break;
 }
 return 0;
}

Message 8 of 9
(4,832 Views)

thanks wim ..

getindexfrompoint control function works perfectly..

sks

0 Kudos
Message 9 of 9
(4,828 Views)