![]() |
|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
![]() |
|
Опции темы | Поиск в этой теме |
![]() |
#1 |
Регистрация: 17.05.2011
Сообщений: 8
|
![]()
Я делаю тестирующую программу. В программе динамически создаются GroupBox и на них таким же образом создаются RadioButton.
Нужно сделать, чтобы при нажатии кнопки все RadioButton отжимались. Вся программа: unit Unit3; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm3 = class(TForm) Button1: TButton; ListBox1: TListBox; Button2: TButton; Button3: TButton; Button4: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form3: TForm3; i,k, qv, qt, bal: integer; rbut, rbut2: array [1..10] of TRadioButton; gbox: array [1..10] of TGroupBox; f:textfile; implementation uses Unit1, Unit2; {$R *.dfm} procedure TForm3.Button1Click(Sender: TObject); begin if MessageDlg('Вы уверены?', mtConfirmation, mbOkCancel,0)=mrOk then form1.close; end; procedure TForm3.FormCreate(Sender: TObject); Var St : String; Begin Qv := 10; Qt := 1; bal:=0; Case Qt Of 1 : For i:= 1 To Qv Do Begin GBox[i] := TGroupBox.Create(Form3); GBox[i].Parent := Self; GBox[i].Height := 70; GBox[i].Width := 550; GBox[i].Top := I*80-50; GBox[i].Left := 10; RBut[i]:=TRadioButton.Create(GBox[i]); RBut[i].Parent := GBox[I]; RBut[i].Top := 15; RBut[i].Left := 10; RBut2[i] := TRadioButton.Create(GBox[i]); RBut2[i].Parent := GBox[i]; RBut2[i].Top := 45; RBut2[i].Left := 10; AssignFile(f, 't1.txt'); Reset(f); k := 1; While (Not EoF(f)) And (k <= Qv) Do Begin ReadLn(f, St); GBox[k].Caption := St; k:=k+1; End; CloseFile(f); RBut[i].Caption := 'Да'; RBut2[i].Caption := 'Нет'; End; end; End; procedure TForm3.Button2Click(Sender: TObject); begin For i:= 1 To Qv Do if RBut[i].Checked then bal:=bal+1; ListBox1.Visible:=true; if bal<=5 then begin ListBox1.Items.LoadFromFile('u1.txt '); assignfile(f,'u1.txt'); reset(f); while (not eof(f)) do begin readln(f); k:=k+1; end; closefile(f); end; if bal>5 then begin ListBox1.Items.LoadFromFile('u2.txt '); assignfile(f,'u2.txt'); reset(f); while (not eof(f)) do begin readln(f); k:=k+1; end; closefile(f); end; end; procedure TForm3.Button3Click(Sender: TObject); begin //при нажатии этой кнопки должно обнуляться. end; procedure TForm3.Button4Click(Sender: TObject); begin end; end. Когда я не создавал динамически GroupBox, а клал его на форму работало это: for i:=0 to (self.componentcount - 1) do if self.components[i] is TRadioButton then (self.components[i] as TRadioButton).Checked:=false; Как это исправить чтобы работало в новой программе? Заранее благодарен. |
![]() |
![]() |
![]() |
#2 |
Ещё не
Форумчанин
Регистрация: 04.01.2010
Сообщений: 517
|
![]() Код:
Воображение важнее, чем знания. (Albert Einstein)
![]() |
![]() |
![]() |
![]() |
#3 |
Регистрация: 17.05.2011
Сообщений: 8
|
![]()
Спасибо! Всё работает
![]() |
![]() |
![]() |
![]() |
![]() |
||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
RadioButton | 29_kapaT | Компоненты Delphi | 1 | 10.05.2010 03:30 |
radiobutton | xxxn00bxxx | Общие вопросы C/C++ | 8 | 25.02.2010 08:06 |
radiobutton | Bon'ka | Компоненты Delphi | 4 | 16.05.2009 21:56 |
RadioButton | Pavelok | Общие вопросы Delphi | 3 | 14.05.2009 14:05 |
вопрос по RadioGroup и RadioButton | Bayazet | Общие вопросы Delphi | 3 | 16.02.2009 17:50 |