Uitable: how to set number of rows/columns
16 次查看(过去 30 天)
显示 更早的评论
Hi guys!
I noticed that there's the possibility of creating tables... I tried to look Property Inspector items, but I didn't understand very much!
According to you there's the possibility to create tables with a variable number of rows and coloum??
For example, if I have an array, can I create a table with a number of rows equal to the length of my array? How can I do?? And what can you tell me about the same questions according to columns??
Thanks a lot!
1 个评论
Michel KOPFF
2012-3-22
Hello!
I want an uitable with only one column.
a = {'A' ; 'B' ; 'C‘};
set(handles.table,'Data',a);
The uitable is shown with 2 columns.
b = get(handles.table,'Data');
b is a <3x1 cell> cell array.
What is the solution that the second column disappear in the uitable?
Thanks.
回答(1 个)
Walter Roberson
2012-1-20
If you are talking about uitable(), you change the number of rows or columns by set() a new Data property. If you are using something other than the defaults for properties such as ColumnFormat then you would want to update those properties as well.
2 个评论
Walter Roberson
2012-1-20
There is no property for the number of rows or columns. The size() of the cell array that is the Data property determines the number of rows and columns. For example if you wanted to add 2 columns,
d = get(handles.Table, 'Data');
d{1,end+2} = [];
set(handles.Table, 'Data', d);
Properties you might want to set() when you update the number of columns include: ColumnEditable, ColumnFormat, ColumnName, ColumnWidth. Properties that you might want to set() when you update the number of rows include: RowName .
There is no explicit specification of number of rows or columns, just the number figured out from the Data property.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dialog Boxes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!