How can I get the index of the selected item in a pop-up menu within a uitable?

I have set up a column as pop-up menu in my uitable as follows:
f=figure;
choices={'A' 'B' 'C' 'A'};
t=uitable(f,'ColumnFormat',{choices}, 'Data', {'';'';''} ,'ColumnEditable',[true]);
I would need to know the index of the selected item within my array choices in uitable's CellEditCallback. I.e., if the user selects 'C' from the menu, the index would be 3. The array of choices can have duplicate values, so I cannot simply use strcmp to match the selected value.
J.

Réponses (2)

Well written question
f=figure;
choices={'A' 'B' 'C' 'A'};
t=uitable(f,'ColumnFormat',{choices}, 'Data', {'';'';''} ,'ColumnEditable',[true],'celleditcallback',@(src,evt)disp(evt));
This should make it pretty clear.

1 commentaire

Thanks, but I was not looking for the indices of the changed table cell. Instead, I would need to know the index of the chosen value within the array of possible choices, which is specified in ColumnFormat. The eventdata structure does not seem to have this information.
The problem is that the pop-up menu within an uitable does not have anything like the 'Value' property of an uicontrol pop-up menu.

Connectez-vous pour commenter.

I don't see how to do this. The best I can suggest to you is to use this file to dig into the underlying JAVA (or don't duplicate strings in the popup!)

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Produits

Tags

Question posée :

le 21 Août 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by