Board index » delphi » Disabling single item in TRadioGroup

Disabling single item in TRadioGroup

Hi.

Does anyone know if it is possible to disable one item in a
TRadioGroup at runtime. Eg to disable the Print: Search Results option
if there are no search results available.... ??? Or do I just have to
use individual radio boxes ?

Ta muchly

Finn

 

Re:Disabling single item in TRadioGroup


In article <348f0c84.42241...@news.dial.pipex.com>, re...@dial.pipex.com (Finn

Quote
Austin) writes:
>Does anyone know if it is possible to disable one item in a
>TRadioGroup at runtime. Eg to disable the Print: Search Results option
>if there are no search results available.... ??? Or do I just have to
>use individual radio boxes ?

I don't know if you can access the individual buttons - although I would expect
that they were held in the TRadioGroup.Items.Objects list.

But you can do it at top level by adding an extra TRadioButton for use as the
one you want to enable/disable.

Position the ExtraRadioButton exactly over the one of the TRadioGroup you want
to disable. Then in the FormCreate enter :-

  with ExtraRadioButton do begin
    Parent := RadioGroup1;
    Top := Top - RadioGroup1.top;
    Left := Left - RadioGroup1.Left;
  end;

You need to do this because the TRadioButton defaults to child of (and hence
position relative to) the form;

Then in TRadioButtonClick enter:-

RadioGroup1.ItemIndex := 2;  {or whatever the ItemIndex of the TRadioGroup
button is}

Voila! all works as you wish when you enable/disable the TRadioButton.

Hope this helps

Alan Lloyd
alangll...@aol.com

Re:Disabling single item in TRadioGroup


You could use the "components" property to accomlish this.  If you
have a TRadioGroup called MyRadioGroup and you wish to disable the button
corresponding to Item 0, try the command:

 ((MyRadioGroup.Components[0]) as TRadioButton).Enabled:=false;

You can change individaul items' colors, fonts, alignment, etc.
this way as well.

-Kerry

In article <348f0c84.42241...@news.dial.pipex.com>,
  re...@dial.pipex.com (Finn Austin) wrote:

Quote

> Hi.

> Does anyone know if it is possible to disable one item in a
> TRadioGroup at runtime. Eg to disable the Print: Search Results option
> if there are no search results available.... ??? Or do I just have to
> use individual radio boxes ?

> Ta muchly

> Finn

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

Other Threads