private void button5_Click(object sender, EventArgs e) { masterlistreport m = new masterlistreport(); masterlistreport.length = dataGridView1.Rows.Count; masterlistreport.data = new string[dataGridView1.Rows.Count, 5];; for (int x = 0; x < dataGridView1.Rows.Count; x++) { masterlistreport.data[x, 0] = dataGridView1.Rows[x].Cells[0].Value.ToString(); masterlistreport.data[x, 1] = dataGridView1.Rows[x].Cells[1].Value.ToString(); masterlistreport.data[x, 2] = dataGridView1.Rows[x].Cells[3].Value.ToString(); masterlistreport.data[x, 3] = dataGridView1.Rows[x].Cells[4].Value.ToString(); masterlistreport.data[x, 4] = dataGridView1.Rows[x].Cells[6].Value.ToString(); } m.ShowDialog(); }
private void button5_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count > 0) { masterlistreport m = new masterlistreport(); masterlistreport.length = dataGridView1.Rows.Count; masterlistreport.data = new string[dataGridView1.Rows.Count, 5];; for (int x = 0; x < dataGridView1.Rows.Count; x++) { masterlistreport.data[x, 0] = dataGridView1.Rows[x].Cells[0].Value.ToString(); masterlistreport.data[x, 1] = dataGridView1.Rows[x].Cells[1].Value.ToString(); masterlistreport.data[x, 2] = dataGridView1.Rows[x].Cells[3].Value.ToString(); masterlistreport.data[x, 3] = dataGridView1.Rows[x].Cells[4].Value.ToString(); masterlistreport.data[x, 4] = dataGridView1.Rows[x].Cells[6].Value.ToString(); } m.ShowDialog(); } else { MessageBox.Show("Empty Record", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }