CheckBox Movement |
尚未結案
|
BorlandUser
中階會員 發表:148 回覆:217 積分:73 註冊:2004-02-19 發送簡訊給我 |
之前在stringgird的某一個colmun到動態create checkbox,但發現原來他是不會移動的,於是加了
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
ck:tcheckbox;
begin
ck:=tcheckbox(stringgrid1.objects[ACol,ARow]);
if(ck<>nil)then begin
ck.Left:=rect.Left;
ck.Top:=rect.Top;
end;
end;
end; 最後終於work,但是如果user move column width,那它又會不懂自己去移動,為何呢?
還有上面的code我曾經過為用一個for-loop去做.因為當user向下個向左移動scrollbar時雖要所以有的checkbox也同時移動,不過最後還是實在不成..為何呢?
有人能指教一下嗎?
|
jest0024
高階會員 發表:11 回覆:310 積分:224 註冊:2002-11-24 發送簡訊給我 |
procedure TForm1.FormCreate(Sender: TObject); var i,j:Integer; Obj:TCheckBox; begin for j:=1 to StringGrid1.RowCount-1 do for i:=1 to StringGrid1.ColCount-1 do begin Obj:=TCheckBox.Create(Self); Obj.Visible:=False; Obj.Parent:=StringGrid1; Obj.Caption:=Format('(%d,%d)',[i,j]); StringGrid1.Objects[i,j]:=Obj; end; end; procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var Ck:TCheckBox; begin CK:=TCheckBox(StringGrid1.Objects[ACol,ARow]); if(CK<>nil)then begin CK.Left:=Rect.Left 2; CK.Top :=Rect.Top; CK.Width :=Rect.Right-Rect.Left; Ck.Height:=Rect.Bottom-Rect.Top; CK.Visible:=True; end; end;學而時習之不亦樂乎! 發表人 - jest0024 於 2004/05/07 23:56:06 |
BorlandUser
中階會員 發表:148 回覆:217 積分:73 註冊:2004-02-19 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |