我一直在試圖添加DataGridViewRow到DataGridView無濟於事。我跟着答案here。我不能爲我的生活找出我的代碼有什麼問題!C#:將DataGridViewRow添加到DataGridView異常
我想用關聯鍵,而不是指數的補充數據:
row.Cells["Column2"].Value = "XYZ";
row.Cells["Column6"].Value = 50.2;
這是我的代碼:
DataGridViewRow dgvr = (dgvSponsor.RowTemplate);
dgvr.Cells["firstName"].Value = fn;
dgvr.Cells["midName"].Value = mi;
dgvr.Cells["lastName"].Value = ln;
dgvr.Cells["suffix"].Value = suffix;
dgvr.Cells["residence"].Value = res;
dgvr.Cells["gender"].Value = radioMale.Checked ? 1 : 2;
爲什麼它仍然拋出異常?
Nah。我嘗試過這個。不起作用。 –