2010-07-01 69 views

回答

3

操縱在Windows行窗體DataGridView控件:http://msdn.microsoft.com/en-us/library/ddtce152.aspx

按鈕的onclick使用dataGridView.Rows.Add加行作爲示例如下所示

// Populate the rows. 
     string[] row1 = new string[]{"Meatloaf", 
              "Main Dish", boringMeatloaf, boringMeatloafRanking}; 
     string[] row2 = new string[]{"Key Lime Pie", 
              "Dessert", "lime juice, evaporated milk", "****"}; 
     string[] row3 = new string[]{"Orange-Salsa Pork Chops", 
              "Main Dish", "pork chops, salsa, orange juice", "****"}; 
     string[] row4 = new string[]{"Black Bean and Rice Salad", 
              "Salad", "black beans, brown rice", "****"}; 
     string[] row5 = new string[]{"Chocolate Cheesecake", 
              "Dessert", "cream cheese", "***"}; 
     string[] row6 = new string[]{"Black Bean Dip", "Appetizer", 
              "black beans, sour cream", "***"}; 
     object[] rows = new object[] { row1, row2, row3, row4, row5, row6 }; 

     foreach (string[] rowArray in rows) 
     { 
      dataGridView.Rows.Add(rowArray); // addding row 
     } 
+0

@Pranay蛙::如果我想添加無限的行然後我做什麼? – 2013-08-02 20:42:47

0

在你的onclick事件中,你是在調用DataTable.Rows.Add()還是類似的?

相關問題