private void button1_Click(object sender, EventArgs e) { if (grid.RowCount == 1) { MessageBox.Show("No Lab tests scheduled for the day!!!"); } else { f_Lab home = this; DataGridViewRow row = grid.CurrentRow; string MRN = row.Cells[0].Value.ToString(); string date = row.Cells[2].Value.ToString(); int mrn = Convert.ToInt16(MRN); labTest test = new labTest(mrn, date); test.Show(); home.Dispose(); } }