|  | 
 
 | 
| 
 | |||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны | 
|  | 
|  | Опции темы | Поиск в этой теме | Опции просмотра | 
| 
			 
			#1  
			
			
			
			
		 | |||
| 
 | |||
|  Edit по аналогии с CheckBox Парни, помогите исправить прогу Anketa2.7z аналогично по Anketa.7z Чтобы тупо все так же было, только Edit вместо CheckBox. Заранее спасибо! | 
| 
			 
			#2  
			
			
			
			
		 | ||||
| 
 | ||||
|   Сода выложить нужные куски кода трудно? | 
| 
			 
			#3  
			
			
			
			
		 | |||
| 
 | |||
|   Код: procedure AllCheckBoxClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    CheckBoxes:array[1..6,1..15] of TCheckbox;
    AllCheckBoxes:array[1..6] of TCheckbox;
    Results:array[1..6,1..15] of integer;
...
procedure TForm1.FormCreate(Sender: TObject);
const
  AllIndex:array[1..6]of integer=(16,32,48,64,80,96);
  StartIndex:array[1..6]of integer=(1,17,33,49,65,81);
var i,j: Integer;
begin
  for i:=1 to 6 do
  begin
    AllCheckBoxes[i]:=TCheckbox(FindComponent('Checkbox'+Inttostr(AllIndex[i])));;
    AllCheckBoxes[i].Tag:=i;
    for j:=1 to 15 do
      CheckBoxes[i,j]:=TCheckbox(FindComponent('Checkbox'+Inttostr((StartIndex[i]+j-1))));
  end;
end;
procedure TForm1.AllCheckBoxClick(Sender: TObject);
var i,j: Integer;
begin
  i:=TCheckbox(Sender).Tag;
  if i in [1..6] then
    for j:=1 to 15 do
      CheckBoxes[i,j].Checked:=TCheckbox(Sender).checked;
end;
procedure TForm1.Button1Click(Sender: TObject);
var i,j: Integer;
begin
  for i:=1 to 6 do
  begin
    for j:=1 to 15 do
    begin
      if CheckBoxes[i,j].Checked then
        inc(Results[i,j]);
      CheckBoxes[i,j].Checked:=false;
    end;
    AllCheckBoxes[i].Checked:=false;
  end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i,j: Integer;
  StrResult,s:string;
begin
  Button1Click(nil);
  StrResult:='';
  for j:=1 to 15 do
  begin
    s:='';
    for i:=1 to 6 do
      s:=s+' | '+IntToStr(Results[i,j]);
    StrResult:=StrResult+s+#13#10;
  end;
  for i:=1 to 6 do
    for j:=1 to 15 do
      Results[i,j]:=0;
  Application.MessageBox(pChar(StrResult),'Результат',MB_OK);
end;
end.Последний раз редактировалось Admin, 26.03.2012 в 22:01. | 
| 
			 
			#4  
			
			
			
			
		 | ||||
| 
 | ||||
|   Хм, интересно, как заменить строки: Код: CheckBoxes[i,j].Checked:=TCheckbox(Sender).checked; | 
| 
			 
			#5  
			
			
			
			
		 | |||
| 
 | |||
|   именно дупля ловлю над этим... | 
| 
			 
			#6  
			
			
			
			
		 | ||||
| 
 | ||||
|   Только, если в Edit писать - True/False. | 
| 
			 
			#7  
			
			
			
			
		 | |||
| 
 | |||
|   подробнее? | 
| 
			 
			#8  
			
			
			
			
		 | ||||
| 
 | ||||
|   У CheckBox, 2(3) состояния Tru/False. Вот их и писать в Edit. |