Clear Filters
Clear Filters

uitable in app designer: format scalar and size cell table

8 views (last 30 days)
hi,
i need to resize the column of table (to use a fixed size)
and i need 1.2964e+04 =====> 129640
i try to use addstyle but i can't find solution

Answers (1)

dpb
dpb on 22 Jun 2023
Well, without code to look at, it's hard to point out what may have done wrong -- a simple test here worked just fine...
p=[20 20 210 80];
hUIF=uifigure('Position',p);
hUIT=uitable(hUIF,'Position',p,'Data',[129640 pi],'ColumnName',{'x','y'},'ColumnWidth',{60 120});
hUIT.ColumnFormat={'short','long'};
Changing the 'ColumnWidth', 'ColumnFormat' properties modifies the table as expected. NOTA BENE: the formatting options aren't very extensive, one of the values recognized by the format function or just one of {'char','logical','numeric'}, ignoring the pop-up menu thingie. Unfortunately, as with the builtin table, setting a specific format string for a given variable/column isn't supported; to do that you'd have to display everything as text and use callback function to format and then display the value.
  6 Comments
dpb
dpb on 22 Jun 2023
Are you still trying to use fixed width columns? If so, try either 'auto' of 'fit' for the numeric columns and see if that helps.
It is very difficult to compute the number of pixels to hold aribtrary number of characters given the variable nature of fonts, fontsize, etc., etc., etc., ... numbers with eights (8) or other wider characters in them will need more display space than a number of the same number of digits comprised of "not so wide" characters. Unless, of course, you revert to a fixed-width font.

Sign in to comment.

Categories

Find more on Tables 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!