пример заполнения DataGridView
SqlConnection conn = new SqlConnection(@"Data Source=192.168.0.1,1433;Network Library=DBMSSOCN;Initial Catalog=test;User ID=test;Password=test;"); String sqlquery = "SELECT orderid FROM Sales.Orders;"; try { conn.Open(); SqlCommand cmd = new SqlCommand(sqlquery, conn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds,"myTable"); dataGridView1.DataSource = ds; dataGridView1.DataMember = "myTable"; } catch (SqlException ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); }
или забить в грид простой массив:
//... try { string[] stuff = new string[] { "One", "Two", "Three" }; dataGridView1.DataSource = stuff; } //...
Комментарии закрыты.