private void button1_Click(object sender, EventArgs e) { try { MessageBoxUtils mbu = new MessageBoxUtils(); int arraysize = mbu.DialogBox("Enter size of the array ", "Data input"); if (arraysize == 0) { throw new Exception(); } ArrayUtils rr = new ArrayUtils(arraysize); int[] array = rr.ArrayCreater(); draw_Arr = array; ArrToDGV(array, DGV); } catch (Exception) { MessageBox.Show("Enter the correct data", "Error"); } }