How can I get the index of the selected item in a pop-up menu within a uitable?
Show older comments
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.
Answers (2)
Sean de Wolski
on 21 Aug 2012
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 Comment
J. Jotakin
on 21 Aug 2012
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!