Просмотр полной версии : как узнать что выделено 4 CheckBox
Leon2009
07.06.2010, 18:07
Здравствуйте! можно ли узнать? у меня на форме 30 CheckBox если из них выделить любые 4 как сделать чтобы хоть сообщение выдал что выделено 4 чекса? спасибо!
переменную сделай++--
зы чтоб OnClick одинаковый обработчик у всех был
ззы вы меня паражаите)
Leon2009
08.06.2010, 01:09
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 чексов? :confused:
т.е одинаковый обработчик?
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 чексов? :confused:
т.е одинаковый обработчик?
var
i, i2: integer;
begin
i2:=0;
for i:=1 to 8 do
begin
if TCheckBox(FindComponent('CheckBox'+inttostr(i))).C hecked=true then
inc(i2);
end;
if i2 = 4 then ShowMessage('Выделенно 4 чекбокса');
end;
M_script_
08.06.2010, 10:25
спасибо!
а если 1000 чексов? :confused:
т.е одинаковый обработчик?
Пример на билдере
обработчик OnClick всех чекбоксов:
void __fastcall TMainForm::CheckBoxClick(TObject *Sender)
{
pCheckBox = static_cast<TCheckBox *>(Sender);
if(pCheckBox->Checked)
Label1->Caption = IntToStr(++iCBCount);
else
Label1->Caption = IntToStr(--iCBCount);
}
vBulletin® v3.8.14, Copyright ©2000-2026, vBulletin Solutions, Inc. Перевод: zCarot