App designer Table with input numbers of rows and columns

36 vues (au cours des 30 derniers jours)
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';

Réponse acceptée

Bhargavi Maganuru
Bhargavi Maganuru le 25 Nov 2019
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!

Plus de réponses (0)

Catégories

En savoir plus sur Develop uifigure-Based Apps dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by