我與測試代碼editted這樣的:
public Form1()
{
InitializeComponent();
//This can be removed before utilizing
dgv.Rows.Add("1", "1", "1");
dgv.Rows.Add("1", "1", "1");
dgv.Rows.Add("bob", "bob", "bob");
dgv.Rows.Add("1", "1", "1");
dgv.Rows.Add("1", "1", "1");
dgv.Rows.Add("1", "1", "1");
//This can be removed before utilizing
int oldrow = 2;
dgv.Rows.Add(itemArray(dgv.Rows[oldrow]));
dgv.Rows.RemoveAt(oldrow);
/*
DataGridViewRow oldRow = dataGridView1.Rows.Add(itemarray(dataGridView1.Rows[1])); dataGridView1.Rows.Remove(oldRow)
*/
}
object[] itemArray(DataGridViewRow Row)
{
int a = Row.DataGridView.ColumnCount - 1;
object[] mOut = new object[a+1];
for (int x = 0;x <= a ; x++)
{
mOut[x] = Row.Cells[x].Value;
}
return mOut;
}
我爲所有附加測試道歉。
它所通過的項目陣列 – Dotnet 2010-09-27 14:57:52
意思,但我沒有得到這樣的 – Dotnet 2010-09-27 15:04:27
我得到一個錯誤的錯誤任何財產不能類型「詮釋」隱式轉換爲「System.Windows.Forms.DataGridViewRow」 – Dotnet 2010-09-27 15:25:35