各位大蝦:
我在datagridview中設置了allowuserstoaddrows的值是true,用一個按鈕遍歷datagridview
的所有行,判斷是不是新增的行。但是不起效果,還是顯示“不是”,請大家幫我看一下。代碼如下。
private void button1_Click(object sender, EventArgs e)
{
DataGridViewRow rom = new DataGridViewRow();
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (rom.IsNewRow)
{
dataGridView1.Rows[i].HeaderCell.Value = "是的";
}
else
{
dataGridView1.Rows[i].HeaderCell.Value = "不是";
}
}
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (dataGridView1.Rows[i].IsNewRow)
{
dataGridView1.Rows[i].HeaderCell.Value = "是的";
}
else
{
dataGridView1.Rows[i].HeaderCell.Value = "不是";
}
}
}