1
votes

I have RadioGroup with many buttons. Now when I add an item, they become smaller and smaller. How is it possible to make them scrollable?

2

2 Answers

3
votes

TRadioGroup does not natively support scrolling. However, what you can do instead is the following:

  1. place a TGroupBox on your UI.

  2. place a TScrollBox onto the TGroupBox, set its Align property to alClient, and its BorderStyle property to bsNone.

  3. 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). This positioning is needed because you cannot turn off the TRadioGroup's borders or the space reserved for its Caption.

  4. 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.

This way, the buttons appear as if they are part of the TGroupBox, but with the added scrollbar(s).

screenshot

2
votes
  1. RadioGroup->Items->Count
  2. TRadioGroup component doesn't have an embedded scrollbar, but you can put the radio group on a TScrollBox for a similar effect.

    You can use the Buttons collection to refer each button, e.g.

    RadioGroup->Buttons[0]->Height = 5;
    RadioGroup->Buttons[1]->Top = RadioGroup->Buttons[0]->Top + 10;
    

    Anyway a TComboBox could also be a good choice.