안녕하세요... 댁스터입니다...
컨트롤을 동적으로 생성하시려면 먼저... 선언부에 선언을 하셔야죠...
예를 들어 버튼 컨트롤로 하죠... 먼저 TButton이 선언된 유닛을
uses절에 추가합니다... uses stdctrls;
그리고, 동적으로 만들 버튼을 선언합니다.
MyBtn: TButton;
그리고 다음과 같이 합니다....
MyBtn := TButton.Create(Self); // 버튼을 생성합니다..
with MyBtn do begin
Parent := Self; // 아래설명 참고
Left := 100; // 버튼의 속성을 정의한다.
Top := 100; // " "
Caption := 'test'; // " "
end;
요렇게 하면 위 코드가 작성되어 있는 이벤트 헨들러가
실행될 때 버튼이 생깁니다..
그리고 Parent 속성에 관한 설명은 도움말을 그대로 옮깁니다...
참고하세요...
Assign the Parent property.
Setting the Parent property is always the first thing to do after
constructing a control. The parent is the component that
contains the control visually; usually it is the form on which
the control appears, but it might be a group box or panel.
Normally, you'll set Parent to Self, that is, the form.
Always set Parent before setting other properties of the control.
THEXDER
|