setfocus至動態產生的元件? |
答題得分者是:Wesly
|
jck1
一般會員 發表:53 回覆:67 積分:24 註冊:2002-05-23 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
|
jck1
一般會員 發表:53 回覆:67 積分:24 註冊:2002-05-23 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
|
huwk
資深會員 發表:26 回覆:340 積分:323 註冊:2002-04-03 發送簡訊給我 |
引言: deleted... 可是當初在產生時並沒有給name 除了用name外還有其他方法嗎? 謝謝!! unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private edtFirstCreate : Tedit; //用變數保持住第一個產生的edit.. { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.FormCreate(Sender: TObject); begin edtFirstCreate := TEdit.Create(self); edtFirstCreate.Parent := Self; end; procedure TForm1.Button1Click(Sender: TObject); begin edtFirstCreate.SetFocus; end; end.
------
熊的學習 http://huwk.blogspot.com |
Wesly
中階會員 發表:14 回覆:103 積分:53 註冊:2002-05-31 發送簡訊給我 |
看看下面的是否為您所需 unit Unit1; interface uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls; type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
ttEdit: Array of TEdit; //動態陣列
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
aLen: Integer;
tTop, tLeft, tHigh: Integer;
begin
if Length(ttEdit) = 0 then //當為空時則產生
begin
//定義動態陣列大小及位置資料
aLen := 5;
tTop := 40;
tLeft := 10;
tHigh := 30;
//
SetLength(ttEdit, aLen); //設定陣列長度
//建立物件及顯示
for i := 0 to aLen - 1 do
begin
ttEdit[i] := TEdit.Create(nil);
ttEdit[i].Parent := Self;
ttEdit[i].Top := tTop;
ttEdit[i].Left := tLeft;
Inc(tTop, tHigh);
end;
end;
ttEdit[0].SetFocus; //對映至第一個動態產生物件
end; end.
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |