How can I create an uitable with one column as strings and second column as checkboxes?

20 visualizaciones (últimos 30 días)
I want to have an uitable with two columns: the first column contains names (format of the column is set to Let MATLAB choose) and the second column contains checkboxes (format Logical, Editable).
I am trying to fill the table using the code:
tableContent = {names include};
set(handles.uitable1,'Data',tableContent);
where names is a cell array (size n*1) and include is a logical array (size n*1).
I get the error: Error using set Values within a cell array must be numeric, logical, or char
I have also unsuccesfully tried to convert names to char. Is there any way to do that?
Thank you.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 27 de Feb. de 2013
Editada: Azzi Abdelmalek el 27 de Feb. de 2013
f = figure('Position',[100 100 400 150]);
names={'name1';'name2';'name3'}
checkbox1={false;false;false}
yourdata =[names checkbox1]
columnname = {'name', 'check'};
columnformat = {'char', 'logical'};
columneditable = [true true];
t = uitable('Units','normalized','Position',...
[0.1 0.1 0.9 0.9], 'Data', yourdata,...
'ColumnName', columnname,...
'ColumnFormat', columnformat,...
'ColumnEditable', columneditable,...
'RowName',[] ,'BackgroundColor',[.7 .9 .8],'ForegroundColor',[0 0 0]);
%For more details
help uitable
  6 comentarios
John K. George
John K. George el 13 de Jul. de 2021
Hi, I would like to incorporate this code in App Designer. Please see attached screenshot. How would I proceed? Thank you for any suggestions.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by