uitable background outside cells
18 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm building a GUI all programmatically, with a dark background. UItable has white background outside of populated cells. Is it possible to change it to black/other color?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/973835/image.png)
I have tried with LayoutGrid and Panel, but got no luck with R2022a on Mac:
f = uifigure('Color','k'); % black background in figure
g = uigridlayout(f,'BackgroundColor','k'); % explicit black in the grid
% p = uipanel(g,'BackgroundColor','g'); % table not visible when on a panel
uit = uitable(g,'BackgroundColor',[0 0 0],...
'ForegroundColor',[0 1 0], 'Data',rand(3)); % table on a grid
Another workaround
If background color outside cells is not possible to change, then maybe it is possible to dynamically shorten the table "area", such that if the table has few raws, then its total height is shorter? I'm not sure how to do it. The number of table raws is known (it is dynamic; can change in app upon user interraction), but how adjust the table size based on this? Only the table height needs to be adjusted.
It is also unclear who gives the white background, the uitable or the grid? Maybe the grid needs to be reduced and not the table?
Thanks!
0 Commenti
Risposta accettata
Voss
il 22 Apr 2022
The white background outside the cells of the uitable is part of the uitable itself. Unfortunately, setting that color is not supported (or at least not documented).
You can use your workaround where you set the 'Position' of the uitable according to the size of the region where the cells are. You might use the uitable's 'Extent' for this, and you may need to take into account 16 pixels or so of space on the bottom and the right of the uitable for the "scroll" sliders that appear when the cells of the uitable extend beyond its position.
Più risposte (1)
William
il 20 Nov 2023
Modificato: William
il 20 Nov 2023
So, I had the same problem as you did, what fixed it was messing with the RowHeight and ColumnWidth Property of the uigridlayout. If you play around with that, you should eventually remove the white area as what matlab refers to as the "enclosing rectangle" according to its documentation of uitable under the Extent property. Also adjusting the uitable property "ColumnName" which adjust the column name width may be helpful to minimizing the white area. Hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!