This question already has an answer here:
I'm trying to show a Message box on button clicked for the Checked Checkboxes in Datagridview
Here is my code:
private void btnSave_Click(object sender, EventArgs e)
{
for (int i = 0; i < PayingDG.Rows.Count; i++)
{
if (PayingDG.Rows[i].Cells[4].Value.ToString() == "yes")//this is the checkbox column
{
MessageBox.Show(i.ToString());
}
}
}
It gives the following error:
Object reference not set to an instance of an object.
Any suggestions?
Aucun commentaire:
Enregistrer un commentaire