Filter löschen
Filter löschen

Uitable gui different size on different computers

4 Ansichten (letzte 30 Tage)
James Boyle
James Boyle am 16 Mai 2017
Kommentiert: James Boyle am 17 Mai 2017
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;

Akzeptierte Antwort

Cam Salzberger
Cam Salzberger am 16 Mai 2017
Bearbeitet: Cam Salzberger am 16 Mai 2017
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 Kommentar
James Boyle
James Boyle am 17 Mai 2017
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;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by