GUI - Choice list. diffrent row - diffrent choices

2 vues (au cours des 30 derniers jours)
Martin Poulsen
Martin Poulsen le 8 Mar 2019
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,

Réponses (1)

TED MOSBY
TED MOSBY le 2 Juil 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!

Catégories

En savoir plus sur App Building dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by