2017-06-03 22 views
0

我想從另一個類添加一個字符串到數據網格視圖。C# - 無法添加項到另一個類的數據網格視圖

這裏是我的代碼:

public void AddGridViewRows(string SuccessProxy, string SuccessURL) 
{ 

Console.WriteLine("Called AddGridViewRows"); 

int row = 0; 
dataGridView2.Rows.Add(); 
row = dataGridView2.Rows.Count - 1; 

dataGridView2["doneProxy", row].Value = SuccessProxy; 
dataGridView2["doneStatus", row].Value = "Passed Splash"; 
dataGridView2["doneURL", row].Value = SuccessURL; 

dataGridView2.Update(); 

Console.WriteLine("Successfully added to grid"); 
} 

控制檯同時返回,但沒有出現在數據網格視圖。

回答

0

您可以使用

public void AddGridViewRows(string SuccessProxy, string SuccessURL) 
{ 
Console.WriteLine("Called AddGridViewRows"); 
dataGridView2.Rows.Insert(0, SuccessProxy, "Passed Splash", SuccessURL); 
Console.WriteLine("Successfully added to grid"); 
} 
+0

我試過,但它仍然沒有做任何事情。 – Andre

+0

它說什麼? – Adnand

+0

你的datagridview有多少列? – Adnand

相關問題