Forum > LCL
Creating "TEdit" component dynamically
pascal111:
I'm trying to create "TEdit" component dynamically, but I see no result.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- var Form1: TForm1; e1:tedit; procedure TForm1.FormCreate(Sender: TObject);begin e1:=tedit.Create(self); e1.Height:=28; e1.Width:=127; e1.Left:=95; e1.Top:=56; e1.Text:='Hello World!'; end; procedure TForm1.FormDestroy(Sender: TObject);begin e1.Free;end;
dseligo:
You didn't set parent:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---e1.Parent:=Self;
pascal111:
It works!
Thanks!
alpine:
One more thing, since you gave an Owner to the TEdit by:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---e1:=tedit.Create(self);
You shall not free it at FormDestroy(). It will be freed by the Owner at the right time.
pascal111:
I got it! thanks!
Navigation
[0] Message Index
[#] Next page