Is there a way to avoid scrollbars in an uitable?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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.
Walter Roberson
2020 年 9 月 13 日
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
Mike D.
2020 年 9 月 13 日
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.
Walter Roberson
2020 年 9 月 13 日
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
