在显示该表单之前,我在第二个表单上设置了两个radiobuttons的Checked属性。每次单击按钮以设置Checked属性并显示表单我反转(“NOT”)Checked for each radiobutton。然后在显示表格时,可以清楚地看到发生的无线电按钮的动画(检查属性被更改)。它不会在第一次运行时发生,但会在表单的每个后续显示中发生。
我想阻止动画,只需让radiobuttons在显示表单时显示新设置的检查状态。有办法吗?
在设置Checked之前将无线电按钮放在禁用的面板上或使它们不可见不起作用。
Form1中:
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses Unit2;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.RadioButton1.Checked := not Form2.RadioButton1.Checked;
Form2.RadioButton2.Checked := not Form2.RadioButton1.Checked;
Form2.Show;
end;
Form1 DFM:
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 81
ClientWidth = 249
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 36
Top = 24
Width = 157
Height = 25
Caption = 'Set Radios and Show Form2'
TabOrder = 0
OnClick = Button1Click
end
end
窗体2:
type
TForm2 = class(TForm)
Button1: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
Hide;
end;
end.
Form2 DFM:
object Form2: TForm2
Left = 0
Top = 0
Caption = 'Form2'
ClientHeight = 131
ClientWidth = 176
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 44
Top = 90
Width = 75
Height = 25
Caption = 'Hide'
TabOrder = 0
OnClick = Button1Click
end
object RadioButton1: TRadioButton
Left = 38
Top = 20
Width = 113
Height = 17
Caption = 'RadioButton1'
TabOrder = 1
end
object RadioButton2: TRadioButton
Left = 38
Top = 44
Width = 113
Height = 17
Caption = 'RadioButton2'
TabOrder = 2
end
end
答案 0 :(得分:1)
Set the DoubleBuffered
property of the TRadioButton
s to True
.