How to position correctly a UITable into a figure (scrollbar disappeared)
2 views (last 30 days)
Show older comments
Hi,
When I try to create this table the scrollbar disappears.
I need to load in this table approx data from a matrix of approx 200x8 cells and I'm trying to put it into a figure, but unfortunately as soon as I try to touch the position of the table, the scrollbar disappears and then I cannot scroll the table and the table columns names...
I've already had a look to the table properties but it seems there's no possibility to force enabling the table's scroller.
Thanks a lot for the help! :)
%% sample data creation
Strats_tab = strings(200,8);
Strats_tab(:,1) = deal("abcdefghilmnopqrstuvzabcdefghilmnopqrstuvz");
Strats_tab(:,2:5) = deal(datestr(today,'dd/mm/yyyy'));
Strats_tab(:,6:end) = deal(num2str(10^5,'%.0f'));
%% table+fig creation
strats_fig = figure('Position', [0 0 100 100]);
colnames = {'Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5', 'Column 6', 'Column 7', 'Column 8'};
settings_table = uitable(strats_fig, 'Data', cellstr(Strats_tab), 'ColumnName', colnames);
%set(settings_table,'ColumnWidth',{200,300});
table_extent = get(settings_table,'Extent');
set(settings_table,'Position',[0 0 table_extent(3) table_extent(4)+5],'RowStriping','on','FontSize',8,'RearrangeableColumns','on');
figure_size = get(strats_fig,'outerposition');
ssz = get(groot,'ScreenSize');
%desired_fig_size = [max(0,(ssz(3)-table_extent(3)+15)/2),max(0,(ssz(4)-table_extent(4)+65)/2), table_extent(3)+15,table_extent(4)+65]; %old
desired_fig_size = [figure_size(1) figure_size(2) table_extent(3)+15 table_extent(4)+65];
set(strats_fig,'outerposition', desired_fig_size);
strats_fig.MenuBar = 'none';
2 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Downloads in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!