In my main form I have opened a child form using Mdi.
The child form's name is CustomerDetails. In that form if I want to Update or Delete already existing Customer, I have added a button in front of CustomerName in CustomerDetails. On click of that button a new form is opened, named CustomerRecord. In that form I have used DataGridView and I have written code to retrieve the data from database to it.
Now I want that if dataGridView1_RowHeaderMouseClick is clicked, I want to get the selected row in that CustomerDetails form.
The code that i have written in CustomerRecord Form
frmCustomerDetails cd;privatevoid dataGridView1_RowHeaderMouseClick(object sender,DataGridViewCellMouseEventArgs e){try{DataGridViewRow dr = dataGridView1.SelectedRows[0];this.Hide();if(cd ==null|| cd.IsDisposed){
cd =new frmCustomerDetails();
cd.MdiParent=new frmDairyManagementSystem();
cd.WindowState=FormWindowState.Maximized;
cd.Show();}else
cd.Activate();
cd.txtCustomerID.Text= dr.Cells[0].Value.ToString();
cd.dateTimePicker1.Text=dr.Cells[1].Value.ToString();
cd.txtCustomerName.Text= dr.Cells[2].Value.ToString();
cd.grpGender.Text=dr.Cells[3].Value.ToString();
cd.txtAddress.Text= dr.Cells[4].Value.ToString();
cd.txtPhone.Text= dr.Cells[5].Value.ToString();
cd.txtEmail.Text= dr.Cells[6].Value.ToString();
cd.txtMobileNo.Text= dr.Cells[7].Value.ToString();
cd.txtNotes.Text= dr.Cells[8].Value.ToString();
cd.btnUpdate.Enabled=true;
cd.btnDelete.Enabled=true;
cd.btnSave.Enabled=false;
cd.txtCustomerName.Focus();}catch(Exception ex){MessageBox.Show(ex.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);}}The data is not going on my CustomerDetails form.
Please help me out How i can retrieve in my form without creating a new form method.