Is there a way to avoid scrollbars in an uitable?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi, I like to print some specific values beside a plot in an uitable und save it to a pdf. My uitable always creates scrollbars, so if I open the pdf I'm not able to see all values because I cannot scroll the bars anymore. I'm wondering if there is an option I can set to avoid the scrollbars and always get the fullsize of the uitable on my figure? Thanks for helping!
채택된 답변
Susanne Kiefer
2018년 9월 14일
편집: Walter Roberson
2020년 9월 13일
I got an answer from matlab support and I want to share the solution with you: You can try to resize the uitable manually to its fullsize. When you define a uitable object it includes a property called 'Extent' which tells you exactly the size the table would need to have for it to come without scrollbars. After refering to the following example, I got the right behaviour:
f = figure; t = uitable(f,'Data',randi(100,10,3),'Position',[20 20 262 100]); t.Position(3:4) = t.Extent(3:4);
댓글 수: 7
This code does not work for UIFigure. (R2019b)
>> f = uifigure; t = uitable(f,'Data',randi(100,10,3),'Position',[20 20 262 100]);
>> t.Extent(3:4)
ans =
0 0
Your second line showing "t.Extent(3:4)" should instead show "t.Position(3:4) = t.Extent(3:4)", which sets the position size equal to the extent size.
But yea I tried this for an app GUI using UIFigure and the Extent property is always [0, 0, 0, 0]. The only way I figured out how to remove the horizontal scroll bar is to keep increasing the Position(3) value until it disappears, but that's wider than I wanted.
No, for uifigure, Extent is all 0.
uitable created within uifigure have a different set of properties than uitable created within figure:
There does not appear to be anything equivalent to Extent for uitable within uifigure
I'm just trying to display a single column list of numbers in a UIFigure, that the user can edit and using uitable I need to make it width 110 before the horizontal scroll bar disappears. My numbers are all intergers and the widest/largest value is only about 1/3 the width of the column, and my column name is also only 1/3 the width. Not sure why Matlab chooses to make it so wide before horizontal scroll bar disappears. It would be nice if uitable could allow more control over the width of the columns.
I agree, for uitable within uifigure, the operation is not clear.
In the test I did, with numbers in the range +/- 9999, I needed width 132, at which point the widest number was at most half of the column width. Changing the font made very only a slight difference: with a very small font I could get it down to 131, but I also had to hit font sizes up to the 40's before triggered a scroll bar. There was also some hysterisis, with it requiring a wider width (up to 134) for a given large font size if I was controlling the width, but when I started with width 132 I was able to increase the font size through that same point, so the size requirements calculated when changing font size are not the same as the size requirements calculated when changing the width for a given font size.
Unfortunately it is all built-in methods, so we cannot examine them.
Arnav from tech support figured it out for me (for a UIFigure uitable). He said to set the position property width (for example 70), then set the column width to be about 20 less (50 pixels) to allow for the width of the vertical scroll bar. This will prevent a horizontal scroll bar. It works! My numbers are up to 220000 (six digits) taking up about 75% of the width of the column (not including the width of the vertical scroll bar). I'm using courier new font with size 10.
Seems rather clunky? Suggests perhaps that, besides 'auto' and 'fit', a third option ('fill'?) which allows designated column(s) to (exactly) partition the remaining width would save a lot of grief.
I note that trying to hide a one or more columns, by setting width(s) to zero, makes scrollbar avoidance even less intuitive (if it's possible at all). Perhaps I was seeing hysterisis analogous to that suggested by @Walter Roberson above.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
