MATLAB Answers

Keep uitable's column width after setting its data property

조회 수: 6(최근 30일)
Song Decn
Song Decn 15 Jul 2018
댓글: Song Decn 20 Jul 2018
Hi, I have a following issue and hope that someone can help me. Like in the embedded gif:
1. Since i cant see all the variable names, I change the column width
2. Resizing the table would not alter the column width again
3. BUT(!) if I set the table data with another content and change its data property, then the column width go back to its original values. And this is really annoying.
Can someone help to solve this? I assume this must use some java technics.

  댓글 수: 0

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

답변(1개)

Jens-Christian Meiners
Based on the behavior you describe, I guess that the ColumnWidth property for the column in question of your uitable is set to 'auto'. Setting it initially to a fixed number still allows you to resize the column, but should stop the automatic resizing based on data content.

  댓글 수: 1

Song Decn
Song Decn 20 Jul 2018
Hi Jens, setting columnwidth to fixed size is not working. for example run following codes:
f = figure();
t = uitable(f, 'unit', 'normalized', 'Data',randi(100,10,3), ...
'columnwidth', {50, 70, 100}, ...
'Position',[0.2 0.2 0.5 0.5]);
set(f, 'resizefcn', 't.Data = randi(100,10,3);');

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

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by