'select all values of one column from datagridview to a cell in other datagridview

Hi everyone please I want you're help if it's possible :

In the first Form I have a DataGridView and TextBoxes that send data to another DataGridView in the second form when I click the button Télécharger PDF without selecting rows it select all automatically:

  • The problem is that I want to add all value of the first column for example "Arduino + scotch" in cell of the second DataGridView.
  • I think it will be the same way for the total I want to add the Sum in one cell of the form2.

Form1

Form2

Form1:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
     private void button1_Click(object sender, EventArgs e)
    {
         Form2 f2 = new Form2();

            string firstcol = textBox3.Text;
            string secondcol = textBox1.Text;
            string thirdtcol = dataGridView1.CurrentRow.Cells[0].ToString();
            string fourcol = dataGridView1.CurrentRow.Cells[4].ToString();

   //thirdcole and fourcol are not working even for 1 row

            string[] rows = { firstcol, secondcol, thirdtcol, fourcol };

            f2.dataGridView1.Rows.Add(rows);

            f2.Show();

            this.Hide();
        
    }

Form2 :

public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();
    }

    private void A_commande_etat_Load(object sender, EventArgs e)
    {

    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source