Uitable: how to set number of rows/columns

19 次查看(过去 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
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
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 个评论
Jethro
Jethro 2012-1-20
Uhm, yes I wanted to use set()... but I don't know what kind of parameters I have to add...
Can I do something like
set(handles.Table, 'ncolumns_param', length(array)); ????
Walter Roberson
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 CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by