Здравствуйте! можно ли узнать? у меня на форме 30 CheckBox если из них выделить любые 4 как сделать чтобы хоть сообщение выдал что выделено 4 чекса? спасибо!
наверное так Code: var i:integer; begin i:=0; if CheckBox1.Checked= true then i:=i+1; if CheckBox2.Checked= true then i:=i+1; if CheckBox3.Checked= true then i:=i+1; if CheckBox4.Checked= true then i:=i+1; if CheckBox5.Checked= true then i:=i+1; if CheckBox6.Checked= true then i:=i+1; label1.Caption:=inttostr(i); if i>=3 then label2.Caption:='bolshe ili ravno 3'; спасибо! а если 1000 чексов? т.е одинаковый обработчик?
Code: var i, i2: integer; begin i2:=0; for i:=1 to 8 do begin if TCheckBox(FindComponent('CheckBox'+inttostr(i))).Checked=true then inc(i2); end; if i2 = 4 then ShowMessage('Выделенно 4 чекбокса'); end;
Пример на билдере обработчик OnClick всех чекбоксов: PHP: void __fastcall TMainForm::CheckBoxClick(TObject *Sender) { pCheckBox = static_cast<TCheckBox *>(Sender); if(pCheckBox->Checked) Label1->Caption = IntToStr(++iCBCount); else Label1->Caption = IntToStr(--iCBCount); }