Recent

Author Topic: Is it possible to make some items of TRadioBox disabled?  (Read 206 times)

kinlion

  • New Member
  • *
  • Posts: 45
  • I Love Lazarus
Is it possible to make some items of TRadioBox disabled?
« on: August 13, 2019, 08:00:25 am »
Hi, all,

I want to disable some items of a radiobox. That is, user can't check those items under some condition.
But I don't know how to.
Is it possible to do this?

Thanks in advance!
Lazarus 1.8.4 / FPC 3.0.4 / SVN 57972
On Win10 X64, have to compile for Win32

wp

  • Hero Member
  • *****
  • Posts: 6491
Re: Is it possible to make some items of TRadioBox disabled?
« Reply #1 on: August 13, 2019, 09:55:55 am »
RadioBox? You probably mean a TRadioGroup?

You get access to the individual buttons of a TRadioGroup by means of the Controls[] property; you must cast them to TRadioButton, though:
Code: Pascal  [Select]
  1.   // Disable the radiobutton #1 of Radiogroup1
  2.   TRadioButton(RadioGroup1.Controls[1]).Enabled := false;  

Alternatively and less hacky, you can use a TGroupbox and add the radio buttons separately; this way you have full control of the radiobuttons without any tricks.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10