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

조회 수: 6 (최근 30일)
Niko
Niko 2014년 8월 12일
답변: Daniel Dolan 2024년 5월 2일
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
Niko
Niko 2014년 8월 12일
편집: Niko 2014년 8월 12일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Daniel Dolan
Daniel Dolan 2024년 5월 2일
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.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by