c# datagridview 赋值

2024-11-27 08:35:18
推荐回答(1个)
回答1:

string[] a1 = new string[5] { "0", "1", "2", "3", "4" };
string[] a2 = new string[5] { "0", "1", "2", "3", "4" };

for (int i = 0; i < dataGridView1.ColumnCount; i++)
{
if (i > strs.Length) break;
dataGridView1.Rows[0].Cells[i].Value = a1[i];
dataGridView1.Rows[1].Cells[i].Value = a2[i];
}