PDA

View Full Version : آرایه ای از BitBtn



saeidsg
سه شنبه 15 آذر 1390, 00:33 صبح
با سلام خدمت دوستان
میخواستم آرایه ای از BitBtn در داخل یک TabSheet ساخته شود
در کد زیر ساخته می شود ولی در روی فرم ساخته می شود در جای مورد نظر من نیست
procedure TMainProg.FormShow(Sender: TObject);
var
ctrlCount,i,iCountButtom: Integer;
Top, ICountFull,ICountFree : Integer;
;
begin
SetLength(buttonsArray, Dbs.RoomTbl.RecordCount);
i := 0;
iCountButtom := 0;
Top := 150;
Dbs.RoomTbl.First;
while not Dbs.RoomTbl.Eof do begin
buttonsArray[iCountButtom] := TdxButton.CreateParented(c);
buttonsArray[iCountButtom].Width := 50;
buttonsArray[iCountButtom].Align := alNone;
if i = 15 then begin
Top := buttonsArray[iCountButtom].Height + Top + 30;
i:=0;
end;
buttonsArray[iCountButtom].Top := Top;
buttonsArray[iCountButtom].Left := 150+(50*i)+(i*3);
buttonsArray[iCountButtom].Height := 50;
buttonsArray[iCountButtom].Caption := Dbs.RoomTbl.FieldByName('NumberRoom').AsString;
buttonsArray[iCountButtom].Color := clYellow;

buttonsArray[iCountButtom].Parent := Self;
buttonsArray[iCountButtom].Hint := Dbs.RoomTbl.FieldByName('NumberRoom').AsString;
buttonsArray[iCountButtom].ShowHint := True;
Inc(i);
buttonsArray[iCountButtom].ControlStyle := buttonsArray[iCountButtom].ControlStyle + [csClickEvents];
buttonsArray[iCountButtom].OnClick := MainProg.Label1.OnClick;
buttonsArray[iCountButtom].Colors.BackgroundFrom:= clRed; //$00F5BF76;
buttonsArray[iCountButtom].Layout := blGlyphTop;
if buttonsArray[iCountButtom].Caption = '110' then begin
buttonsArray[iCountButtom].Colors.BackgroundFrom:= clRed;
end;
ImgMain.GetBitmap(iCountButtom, buttonsArray[iCountButtom].Glyph) ;
Dbs.RoomTbl.Next;
Inc(iCountButtom);
end;

SAASTN
سه شنبه 15 آذر 1390, 15:42 عصر
به خاطر این خطه:
buttonsArray[iCountButtom].Parent := Self;

self تو اون کد به MainProg اشاره می کنه و باعث میشه Parent دکمه برابر خود فرم باشه. به اینصورت تغییر بدید:
buttonsArray[iCountButtom].Parent := TabSheet1;

ضمنا برای قرار دادن کد از تگ PASCAL یا همون ابزار PAS ویرایشگر استفاده کنید تا کد قابل خوندن باشه.