GUI - Choice list. diffrent row - diffrent choices

2 ビュー (過去 30 日間)
Martin Poulsen
Martin Poulsen 2019 年 3 月 8 日
回答済み: TED MOSBY 2025 年 7 月 2 日
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,

回答 (1 件)

TED MOSBY
TED MOSBY 2025 年 7 月 2 日
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!

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by