Problem with uitable with Logical cell and default value of 'true'

1 次查看(过去 30 天)
I'm trying to build a uitable 1x2.
Cell(1,1) format is a 'logical'; Cell(1,2) is 'char'
handles.SeedTable = uitable(...
'ColumnName',{'Shuffle' 'Seed#'},...
'ColumnFormat',{'logical','char'},...
'ColumnEditable',[true true],...
'RowName',{'Seed'},...
'Data',[{'true'}, {'Random#'} ]);
When I run my file:
When I press the checkbox to uncheck cell(1,1) nothing happens. If i do not set the cell to be true by default - all is good (i.e. remove the line:
'Data',[{'true'}, {'Random#'}

采纳的回答

Sean de Wolski
Sean de Wolski 2013-3-13
This is because 'True' is interpretted as a string for which any non-zero value is true. Thus it will always be true.
Replacing with true should resolve this:
uitable(...
'ColumnName',{'Shuffle' 'Seed#'},...
'ColumnFormat',{'logical','char'},...
'ColumnEditable',[true true],...
'RowName',{'Seed'},...
'Data',[{true}, {'Random#'} ]);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Elementary Math 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by