Hi All
I am looking for a way to pass certain columns from a datagridview to a previous form. The columns i want passed is clientname, contactdetails, email, cellphonenumber, telephonenumber and faxnumber.
How it works is as follow:
In my form I have some read-only textboxes. Above them I have a button which takes me to the client form, but keeps the previous form open. In my client form I want to select a row from the datagridview and pass the column values mentioned above to the previous forms textboxes.
This is my code so far:
private void addClientToJobBtn_Click(object sender, EventArgs e)
{
try
{
//Reading the selected row in the current datagrid and then passing it on to the user edit form
String ClientName = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[1].Value.ToString();
String ContactPerson = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[2].Value.ToString();
String CellPhoneNumber = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[3].Value.ToString();
String TelephoneNumber = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[4].Value.ToString();
String FaxNumber = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[5].Value.ToString();
String EmailAddress = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[6].Value.ToString();
AddJob aj = new AddJob(this, ClientName, ContactPerson, CellPhoneNumber, TelephoneNumber, FaxNumber, EmailAddress);
aj.Show();
this.Close();
}
catch (ArgumentOutOfRangeException err)
{
MessageBox.Show("Select a client first");
}
}
It doesn't work though..How can I make it return to the previous form, pass the values and also close the current form?
Any help please??