How to add a column to a UItable in AppDesigner
17 次查看(过去 30 天)
显示 更早的评论
I have created a UITable. I have a button which I want the user to be able to add a column and assign there own name to it.
I can rename a column: app.UITable.ColumnName{1} = 'mark';
I can add a name: app.UITable.ColumnName{end+1} = 'mark';
but when I add it does not display, why not?
0 个评论
回答(1 个)
Simon Chan
2022-1-20
I think it is better to record the number of columns in the uitable before you added a new column and assign the name to the new column as follows:
Nc = length(app.UITable.ColumnName); % Record the original number of columns in uitable
%
% Your code adding new column in the uitable
%
app.UITable.ColumnName{Nc+1} = 'New Column'
4 个评论
Simon Chan
2022-1-20
I am a little bit confuse now.
If you want the data inside the table to display the ColumnName as well, add one more line as follows:
app.UITable.Data(:,end+1)={''}; % add column
app.UITable.Data(:,end)=new_name; % Put the name inside the new column
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!