private void btn_RAF_Click(object sender, EventArgs e) { //updates the random access file to the currently selected layout RandomAccessFile.UpdateRafFile(root.Layout); try { //search for the student string cellData = RandomAccessFile.FindRecord(Convert.ToInt32(tb_search.Text)); student = MainWindowController.FindStudent(root, cellData); UpdateStudentList(cellData); //gets all the information about the student Layout layout = MainWindowController.FindStudent(root, cellData); //highlight the cell of the student dgv_class.CurrentCell = dgv_class.Rows[layout.Vertical].Cells[layout.Horizontal]; } catch (Exception) { if (string.IsNullOrWhiteSpace(tb_search.Text)) { MessageBox.Show("Please enter a record number and try again.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //name has to match and if not show message MessageBox.Show("There is no student at that record number, please try again.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }