How to create Datagridview control dynamically in C#

Feb 18 2009 5:37 AM

hii friends , i want your need . actually i want to create datagridview control dynamically . plz chk following code

DataSet ds = new DataSet();

string q = "Select * From MusterDb_State_Master";

MusterConnection.cmd = new System.Data.OleDb.OleDbCommand(q, MusterConnection.con);

MusterConnection.adp = new System.Data.OleDb.OleDbDataAdapter(MusterConnection.cmd);

MusterConnection.adp.Fill(ds);

DataGridView d1 = new DataGridView();

d1.DataSource = ds.Tables[0];

d1.Show();

this code didn't  give me any error but does not show any control on to the form


Answers (2)