Create Control at Runtime
-
I use this code to create DataGrid at runtime but when I call this function nothing appeare on the form.
DataGrid filtergrid=new DataGrid(); filtergrid.Top=300; filtergrid.Height=100; filtergrid.Width=280; filtergrid.Left=0; filtergrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; filtergrid.Visible=true; filtergrid.Show(); filtergrid.DataSource= myDataView.Table;
What I miss here? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
Wish You Were Here-Pink Floyd-1975 -
I use this code to create DataGrid at runtime but when I call this function nothing appeare on the form.
DataGrid filtergrid=new DataGrid(); filtergrid.Top=300; filtergrid.Height=100; filtergrid.Width=280; filtergrid.Left=0; filtergrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; filtergrid.Visible=true; filtergrid.Show(); filtergrid.DataSource= myDataView.Table;
What I miss here? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
Wish You Were Here-Pink Floyd-1975You need to add the control to its parent's Controls collection. In WinForms and ASP.NET
this.Controls.Add( filtergrid );
assumingthis
is the form or page class that the grid will be added to. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978