Uitable gui different size on different computers

2 次查看(过去 30 天)
I have a table of data in my gui that displays fine and where I want it to be. However when run on a different machine, the table itself is in the same place, but the data does not fill the table and there is a white edge around it.
Here is the code for the table and an image of what I mean with the white edge.
The problem appears to be the width of the first column. It is of a different size on separate computers. Any idea how I can set this to be the same? There does not appear to be a variable I can change for it? Thanks.
tonetable = uitable(main_window, 'data', finaldata);
tonetable.ColumnName = {'Value'} ;
tonetable.BackgroundColor = [.4 .4 .4; 1 0.5 0];
tonetable.ForegroundColor = [1 1 1];
tonetable.RowName = {'-----'};
tonetable.Position = [875 85 350 330];
tonetable.ColumnWidth = {128};
tonetable.FontSize = 10;

采纳的回答

Cam Salzberger
Cam Salzberger 2017-5-16
编辑:Cam Salzberger 2017-5-16
Hello James,
Different systems, especially if they have different operating systems, will frequently cause UI components to appear in different sizes. Using 'Position' units of all 'character' can help to make sure any changes scale with the system, and still fit the text contents of the component.
However, for this particular issue, I think there's a much simpler workaround. If you just specify the 'ColumnWidth' property to 'auto', rather than providing an exact value, I believe that they will fill the table, and should fit the text if it is possible to do so. You could even specify the width of one of the columns exactly, and let the other one be 'auto' so that it can grow or shrink to fill the table as necessary. See the examples in the documentation page for both methods.
-Cam
  1 个评论
James Boyle
James Boyle 2017-5-17
Thanks for the answer Cam. The simple solution did not work, as it did not fit to the space I wanted it (I want it to be the same size as a graph next to it). I think I've found a solution however by finding the size of the screen and then scaling the table size to it, meaning it should appear the same regardless of screen resolution etc: Example:
screen_size = get(0,'screensize');
screen_width = screen_size(3);
width_scale = 302/2560;
table_width = width_scale * screen_width;

请先登录,再进行评论。

更多回答(0 个)

类别

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