Effacer les filtres
Effacer les filtres

How to fix the column width of uitable so the user can't change it?

7 vues (au cours des 30 derniers jours)
Niko
Niko le 12 Août 2014
It seems like column width in a uitable is always adjustable by the user which is annoying sometimes... Is there a way to fix it?
Thanks,
Niko
  1 commentaire
Niko
Niko le 12 Août 2014
Modifié(e) : Niko le 12 Août 2014
So I found the answer in case anyone else is looking for it... Diving into underlying java objects again (using the convenient findjobj function by Yair Altman):
jscroll=findjobj(mytablehandle);
jtable=jscroll.getViewport.getView;
jtable.getColumnModel().getColumn(0).setResizable(false);
jtable.getColumnModel().getColumn(1).setResizable(false);
jtable.getColumnModel().getColumn(2).setResizable(false);
...
And use a for loop if your table has variable number of columns.

Connectez-vous pour commenter.

Réponses (1)

Daniel Dolan
Daniel Dolan le 2 Mai 2024
One pure MATLAB fix is to turn off column labels. It's a bit of a pain, but you can insert text labels above each table column if you are clever and/or patient. This keeps users from accidently resizing a column out of existence.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by