Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   radiobuttons (https://www.clubdelphi.com/foros/showthread.php?t=5283)

haffo 15-11-2003 17:29:48

radiobuttons
 
Hola a todos. ¿cómo puedo hacer que un radiobutton deje de estar pulsado?. La idea es que tengo varios, y al pulsar uno de ellos y posteriormente un botón, todos los radiobutton tienen que estar sin pulsar.

Gracias.

marcoszorrilla 15-11-2003 17:40:35

Si como es previsible se trata de un RadioGroup que contiene varios botones:

Código:

procedure TForm1.Button1Click(Sender: TObject);
begin
RadioGroup1.ItemIndex:=-1;
end;

Un Saludo.

haffo 15-11-2003 18:19:17

No es un radiogroup, son varios radiobuttons sueltos. Vale con el mismo código???

marcoszorrilla 15-11-2003 18:25:41

No:
Código:

procedure TForm1.Button1Click(Sender: TObject);
begin
RadioButton1.Checked:=False;
RadioButton2.Checked:=False;
RadioButton3.Checked:=False;
end;

Un Saludo.

haffo 15-11-2003 18:33:14

Gracias por tu ayuda. :D

marcoszorrilla 15-11-2003 18:47:08

Si tienes muchos botones:
Código:

procedure TForm1.Button1Click(Sender: TObject);
var
nCont:Integer;
MiRadio:TRadioButton;
begin

  for nCont:=0 to Componentcount -1 do
  begin

  If Components[nCont] is TradioButton then
  begin
  MiRadio:=Components[nCont] as TradioButton;
  MiRadio.Checked:=False;
  end;

  end;

end;

Un Saludo.

marcoszorrilla 15-11-2003 18:52:20

Código final, así quedaría más compacto:

Código:

procedure TForm1.Button2Click(Sender: TObject);
var
nCont:Integer;
begin
for nCont:=0 to Componentcount -1 do
  begin

  If Components[nCont] is TradioButton then
  begin
    (Components[nCont]as TRadioButton).Checked:=False;
  end;

  end;
end;

Un Saludo.


La franja horaria es GMT +2. Ahora son las 22:08:29.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi