GUI - Choice list. diffrent row - diffrent choices

2 visualizaciones (últimos 30 días)
Martin Poulsen
Martin Poulsen el 8 de Mzo. de 2019
Respondida: TED MOSBY el 2 de Jul. de 2025
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,

Respuestas (1)

TED MOSBY
TED MOSBY el 2 de Jul. de 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!

Categorías

Más información sobre App Building en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by