App designer Table with input numbers of rows and columns

39 次查看(过去 30 天)
Hello!
I want to create a table with the numbers of rows and columns previously requested to the user.
(the number of columns is given by app.colonna and the number of rows is given by app.slice)
In every cell I need a checkbox.
How can i create this table?
fig = uifigure;
tdata = table([false; false; false]);
uit = uitable(fig,'Data',tdata);
uit.Position(3) = 130;
uit.RowName = 'numbered';

采纳的回答

Bhargavi Maganuru
Bhargavi Maganuru 2019-11-25
You can create properties and set the values using following code
properties (Access = private)
Property % Description
colonna=3; %columns
slice=2; %rows
end
You can use following code to create table with the given number of rows and columns and with check boxes in each row.
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
fig = uifigure;
tdata = table('Size',[app.slice, app.colonna],'VariableTypes',["logical","string","string"]); % use “logical” to get checkbox in first column
uit = uitable(fig,'Data',tdata,'ColumnEditable',[true false false]); % columns can be editable if ColumnEditable is true
uit.Position(3) = 130;
uit.RowName = 'numbered';
end
end
Hope this helps!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by