Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   С/С++, C#, Delphi, .NET, Asm (https://forum.antichat.xyz/forumdisplay.php?f=24)
-   -   как узнать что выделено 4 CheckBox (https://forum.antichat.xyz/showthread.php?t=209812)

Leon2009 07.06.2010 18:07

как узнать что выделено 4 CheckBox
 
Здравствуйте! можно ли узнать? у меня на форме 30 CheckBox если из них выделить любые 4 как сделать чтобы хоть сообщение выдал что выделено 4 чекса? спасибо!

sn0w 07.06.2010 18:12

переменную сделай++--

зы чтоб 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:
т.е одинаковый обработчик?

diznt 08.06.2010 01:32

Цитата:

Сообщение от Leon2009
Код:

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))).Checked=true then
    inc(i2);
  end;

 if i2 = 4 then ShowMessage('Выделенно 4 чекбокса');
end;


M_script_ 08.06.2010 10:25

Цитата:

Сообщение от Leon2009
спасибо!
а если 1000 чексов? :confused:
т.е одинаковый обработчик?

Пример на билдере
обработчик 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);




Время: 13:00