I would like to know how to call an event in c#. Practically I have a datagridview double click event which populates textboxes of f2 with values of a selected row in datagridview and shows form2 with these values in their assigned textboxes. Now I would like to do that with a click of a button, say call my datagridview double click event when that button is clicked, below is my double click event ty.
private void kryptonDataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
try
{
frmUpdate f2 = new frmUpdate();
f2.txtboxClearingAgent.Text = kryptonDataGridView1.SelectedRows[0].Cells["Clearing Agent Name"].Value.ToString();
f2.textboxClientCode.Text = kryptonDataGridView1.SelectedRows[0].Cells["Client Code"].Value.ToString();
f2.txtboxClientName.Text = kryptonDataGridView1.SelectedRows[0].Cells["Client Name"].Value.ToString();
f2.txtboxPostalAddress.Text = kryptonDataGridView1.SelectedRows[0].Cells["Postal Address"].Value.ToString();
f2.txtboxTelephone.Text = kryptonDataGridView1.SelectedRows[0].Cells["Telephone"].Value.ToString();
f2.txtboxFax.Text = kryptonDataGridView1.SelectedRows[0].Cells["Fax"].Value.ToString();
f2.txtboxEmailAddress1.Text = kryptonDataGridView1.SelectedRows[0].Cells["E-mail Address 1"].Value.ToString();
f2.txtboxEmailAddress2.Text = kryptonDataGridView1.SelectedRows[0].Cells["E-mail Address 2"].Value.ToString();
f2.txtboxEmailAddress3.Text = kryptonDataGridView1.SelectedRows[0].Cells["E-mail Address 3"].Value.ToString();
f2.txtboxWebsite.Text = kryptonDataGridView1.SelectedRows[0].Cells["Website"].Value.ToString();
f2.txtboxChargeRate.Text = kryptonDataGridView1.SelectedRows[0].Cells["Charge Rate"].Value.ToString();
f2.txtboxTotalDepo.Text = kryptonDataGridView1.SelectedRows[0].Cells["Total Deposit"].Value.ToString();
f2.txtboxAccountBal.Text = kryptonDataGridView1.SelectedRows[0].Cells["Account Balance"].Value.ToString();
f2.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
}
private void kryptonbtnEdit_Click(object sender, EventArgs e)
{
//using (frmUpdate frmUpdate = new frmUpdate())
//{
// DialogResult result = frmUpdate.ShowDialog();
//}
}