Recent

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

kinlion

  • Jr. Member
  • **
  • Posts: 82
  • 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!

wp

  • Hero Member
  • *****
  • Posts: 11916
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.

kinlion

  • Jr. Member
  • **
  • Posts: 82
  • I Love Lazarus
Re: Is it possible to make some items of TRadioBox disabled?
« Reply #2 on: March 02, 2020, 06:59:03 am »
Thanks to wp :)

 

TinyPortal © 2005-2018