I am trying to display the data in the Gridviewer to the form column but whenever I click a row in the DGV I get the error "Index was out of range. Must be non-negative and less than the size of the collection parameter name"
int Key = 0;
private void EmployessDGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
EmpNametbl.Text = EmployessDGV.SelectedRows[0].Cells[1].Value.ToString();
EmpPhoneTb.Text = EmployessDGV.SelectedRows[1].Cells[2].Value.ToString();
EmpAddTb.Text = EmployessDGV.SelectedRows[2].Cells[3].Value.ToString();
EmpPassTb.Text = EmployessDGV.SelectedRows[3].Cells[4].Value.ToString();
if (EmpNametbl.Text == "")
{
Key = 0;
}
else
{
Key = Convert.ToInt32(EmployessDGV.SelectedRows[0].Cells[0].Value.ToString());
}
}