简体   繁体   中英

How to add another Row in DataGridView?

How can I add another Row After filling the first row [0]?

 public void preencherDTG()
    {
        DTG.Rows.Clear();
        for (int i = 0; i < 10; i++)
        {
            DTG.Rows[0].Cells[0].Value = cbModelo.Text;
            DTG.Rows[0].Cells[1].Value = txtPlaca.Text;
            DTG.Rows[0].Cells[2].Value = txtTotal.Text;

        }

    }

maybe I think you should make like following codes.

object [] values = new object [3];
values [0] = cbModello.Text;
values [1] = txtPlaca.Text;
values [2] = txtTotal.Text;

DTG.Rows.Insert (0,values); // insert at first

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM