[英]Scrolling in C++ Builder RadioGroup
I have RadioGroup with many buttons. 我有许多按钮的RadioGroup。 Now when I add an item, they become smaller and smaller.
现在,当我添加一个项目时,它们变得越来越小。 How is it possible to make them scrollable?
如何使其滚动?
TRadioGroup
does not natively support scrolling. TRadioGroup
本身不支持滚动。 However, what you can do instead is the following: 但是,您可以执行以下操作:
place a TGroupBox
on your UI. 在您的UI上放置一个
TGroupBox
。
place a TScrollBox
onto the TGroupBox
, set its Align
property to alClient
, and its BorderStyle
property to bsNone
. 将
TScrollBox
放置在TGroupBox
,将其Align
属性设置为alClient
,并将BorderStyle
属性设置为bsNone
。
place a TRadioGroup
onto the TScrollBox
, clear its Caption
property, and set its Left
property to -2
and its Top
property to -15
(or whatever the TRadioGroup.Font
is set to plus a few extra pixels). 将
TRadioGroup
到TScrollBox
,清除其Caption
属性,并将其Left
属性设置为-2
并将其Top
属性设置为-15
(或将TRadioGroup.Font
设置为加上一些额外的像素)。 This positioning is needed because you cannot turn off the TRadioGroup
's borders or the space reserved for its Caption
. 因为您无法关闭
TRadioGroup
的边框或为其Caption
保留的空间,所以需要此定位。
Tweak the TScrollBox.HorzScrollBar.Range
and TScrollBox.VertScrollBar.Range
properties so they do not scroll far enough to see the TRadioGroup
's right and bottom borders. 调整
TScrollBox.HorzScrollBar.Range
和TScrollBox.VertScrollBar.Range
属性,以使它们滚动的距离不足以看到TRadioGroup
的右边界和底边界。
This way, the buttons appear as if they are part of the TGroupBox
, but with the added scrollbar(s). 这样,按钮看起来就像它们是
TGroupBox
一部分,但是带有添加的滚动条。
RadioGroup->Items->Count
TRadioGroup
component doesn't have an embedded scrollbar, but you can put the radio group on a TScrollBox
for a similar effect. TRadioGroup
组件没有嵌入式滚动条,但是您可以将单选组放在TScrollBox
以获得类似的效果。
You can use the Buttons
collection to refer each button, eg 您可以使用
Buttons
集合来引用每个按钮,例如
RadioGroup->Buttons[0]->Height = 5; RadioGroup->Buttons[1]->Top = RadioGroup->Buttons[0]->Top + 10;
Anyway a TComboBox
could also be a good choice. 无论如何,
TComboBox
也是一个不错的选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.