I have 2 forms.. grid Form has a data Grid View gets its data from database, the second form other form has text boxes similar to the grid View Columns.
i want to select a row in the grid by double clicking and the other form must shown and the text boxes have the values from grid
Error Show
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=HospitalDataStore StackTrace:
at HospitalDataStore.advSearchForm.dataGridView1_CellDoubleClick(Object sender, DataGridViewCellEventArgs e) in D:\Phoenix\px_software\px_projects\ICareProject\HospitalDataStore\HospitalDataStore\advSearchForm.cs:line 105 at System.Windows.Forms.DataGridView.OnCellDoubleClick(DataGridViewCellEventArgs e) at System.Windows.Forms.DataGridView.OnDoubleClick(EventArgs e)
Code is here
private void dataGridView1_CellDoubleClick(object sender,DataGridViewCellEventArgs e){
int rowIndex = e.RowIndex;
DataGridViewRow row = dataGridView1.Rows[rowIndex];
((InPatientForm)docInsForm).lblRegNo.Text = row.Cells[0].Value.ToString();
((InPatientForm)docInsForm).txtSearch.Text = row.Cells[1].Value.ToString();
((InPatientForm)docInsForm).lblName.Text = row.Cells[2].Value.ToString();
this.Close();
}
User contributions licensed under CC BY-SA 3.0