GUI - Choice list. diffrent row - diffrent choices
Show older comments
Is it posible to have a 'choice list' row format which has diffrent choices depending on which row acces it?
somthing like:
set(handles.uitable1, 'ColumnFormat',{'logical','char',{'test1','test2','test3'}});
for the choices in the first row, and
set(handles.uitable1, 'ColumnFormat',{'logical','char',{'test4','test5','test6'}});
for the choices in the second row,
Answers (1)
TED MOSBY
on 2 Jul 2025
Hi Martin,
A UITable shows a drop-down menu whenever the cell value is a scalar categorical. Because every scalar can carry its own set of categories, each row can have a different list. Storing each scalar inside a cell array column lets every row carry a completely different set of categories, so the drop-down is row-specific.
Below is a code snippet for your usage:
function dropdown_example
row1Cats = categorical({'test1','test2','test3'});
row2Cats = categorical({'test4','test5','test6'});
optRow1 = row1Cats(1);
optRow2 = row2Cats(1);
T = table( ...
[true; false ], ...
["Row 1"; "Row 2"], ...
{optRow1 ; optRow2 }, ...
'VariableNames',{'Flag','Label','Choice'} ...
);
f = uifigure('Position',[350 300 440 140]);
uit = uitable(f, ...
'Data', T, ...
'ColumnEditable', [ true true true ], ...
'Position', [20 20 400 100] ...
);
end
This outputs the following table:


Here is more information on "categorical" :
Hope this helps!
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!