필터 지우기
필터 지우기

Uitable column width setting

조회 수: 140 (최근 30일)
Jason
Jason 2014년 12월 23일
답변: Muhammad Suri 2019년 3월 12일
I have seent hat its possible for a uitable to fill the square its created in using guide.
t=handles.uitable1;
% Set width and height
t.Position(3) = t.Extent(3)
t.Position(4) = t.Extent(4)
I also see that t has the following properties:
t =
Table (uitable1) with properties:
Data: [3x5 double]
ColumnWidth: {'auto' 'auto' 'auto' 'auto'}
ColumnEditable: [0 0 0 0]
CellEditCallback: ''
Position: [0.0279 0.0418 1.0354 0.3769]
Units: 'normalized'
Is it possible to set the column widths individually, for example I wanted 1st column to be a certain size and I thought
t.ColumnWidth(1)=20
might work but it doesnt.

채택된 답변

Sean de Wolski
Sean de Wolski 2014년 12월 23일
Yes, it can be a cell array with numbers and 'auto' interleaved.
web(fullfile(docroot, 'matlab/ref/uitable-properties.html'))
Looks like you need to index into a cell for your example:
t.ColumnWidth{1} = 20
Note the curly {} for indexing into the cell.
  댓글 수: 2
Jason
Jason 2014년 12월 23일
Thankyou. I also found that you can do this:
set (handles.uitable1,'ColumnWidth', {48,52,83,83})
Sean de Wolski
Sean de Wolski 2014년 12월 23일
The two commands are doing the same thing. set is the old way, dot notation is the new way starting in 14b. dot notation is faster and in my opinion cleaner.

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

추가 답변 (1개)

Muhammad Suri
Muhammad Suri 2019년 3월 12일
app.UITable.ColumnWidth = {30,30,30,30};

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by