Setting UI table size to start from the top row and have a scroll bar
1 次查看(过去 30 天)
显示 更早的评论
Hello I am trying to plot data in a table but when I set it to size automatically, I lose my scroll bar and hence the ability to see data on top of the figure. The only way for me to do that is to increase my window size, which in this case is unreasonable. I want the output of this function to be a figure where the first row of the table is at the top and there is a scroll wheel on the right hand side.
clear;
figfig = figure('Name','Final Results','NumberTitle','off');clf;
X = rand(150,9);
XCell = cellstr(string(X));
A(1:150,1:9) = string("#FFFFFF");
A = cellstr(A);
outHtml = strcat('<html><table border=0 width=400 bgcolor=', ...
A, ... % Choose the appropriate color for each cell
'"><TR><TD>', ...
XCell, ... % Convert num data to cell of chars
'</TD></TR></body></html>');
u = uitable(figfig,'Data',outHtml);
table_extent = get(u,'Extent');
figure_size = get(figfig,'outerposition');
desired_fig_size = [figure_size(1) figure_size(2) table_extent(3)+15 table_extent(4)+65];
set(u,'outerposition',[1 1 table_extent(3) table_extent(4)])
set(figfig,'outerposition', desired_fig_size);
end
2 个评论
Greg
2018-1-19
A = string("#FFFFFF");
Is redundant. The double quotes give you a string.
A(1:150,1:9)
Is also unnecessary, as strcat will apply implicit expansion to a scalar input.
采纳的回答
Greg
2018-1-19
Not sure why you're using HTML here...
u = uitable(figfig,'Data',outHtml,'Units','normalized','OuterPosition',[0,0,1,1]);
Then remove the other lines dealing with the uitable size/position.
0 个评论
更多回答(0 个)
另请参阅
类别
在 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!