Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to add the content of the current cell in a datagridview to the next cell and to a label text property.

C#
MessegeBox.Show(dgv1.Rows[dgv1.CurrentRow.Index].Cells["creditAmt"].Value.ToString());

here i am getting an error saying that
"Object reference not set to an instance of an object."

can any one send me the solution please
Posted

1 solution

Make sure that dgv1.CurrentRow is not null.
C#
if (dgv1.CurrentRow != null)
{
  // code here
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900