Why does "Auto Width" feature not adapt to table axes size in GUIDE?

37 views (last 30 days)
I'm trying to understand why in GUIDE, when I insert a table element, in the "Table Property Editor", the "Auto Width" feature does not automatically fill in the axes with the total width of the table columns. It seems the number of pixels that is being used as the "maximum width" of the table is being set to something other than the axes width. That seems counterintuitive to me. Is there a way to enable Matlab to, by default, expand the table columns automatically to fill in its containing axes? I spend a lot of time trying to manually adjust these to make it fit.
Kristoffer Walker
Kristoffer Walker on 1 Jul 2019
Thank you, Adam. I guess there could also be an "AutoExpand" option in App Designer if there isn't already one planned. Yes, I see the issue with scrollbars. They should also be "toggleable" to have them automatically turned off from being displayed. There is a similar issue with having row numbers be interpreted as a column, which changes the space budget when transitioning from 9 rows to 10.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 1 Jul 2019
Not that I've been able to figure out. I've noticed also that AutoSize columns does not work for GUIDE. But Autosize is supposed to size the column width according to the widest cell contents in each column, not autosize columns to the width of the table control on your GUI.
The Mathworks is not putting any more work into GUIDE. They're focusing solely on App Designer from now on, so there will be no fix coming from them.
  1 Comment
Kristoffer Walker
Kristoffer Walker on 1 Jul 2019
Many thanks for that explanation. I will keep that in mind for future development.

Sign in to comment.

More Answers (1)

Yair Altman
Yair Altman on 5 Jul 2019
Edited: Yair Altman on 5 Jul 2019
The "AutoWidth" setting of the uitable only sets the individual column's width based on its contents. It does not control the entire table's width. You can easily control this in Matlab, if you are willing to get your hands dirty with the [undocumented] underlying Java control. For this you will need to use the findjobj utility, as follows:
hTable = uitable(...);
jscroll = findjobj(hTable);
jTable = jscroll.getViewport.getView;
I discuss scrollbars, column widths and selection behavior in section 4.1.3 of my book "Undocumented Secrets of Matlab-Java Programming" and [in more detail] in my uitable customization report. You can find various other types of usefull customizations to uitable and other Matlab controls on my UndocumentedMatlab.com website.


Find more on Migrate GUIDE Apps 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!