怎么样让datagridview动态的显示我想做一个抓包的工具,因为包是一个个收到的,所以我需要一行行的添加抓到的包记录,请问怎么实现?

解决方案 »

  1.   

    抓到一个包就datagridview.Rows.Add();
      

  2.   

    两种方法
    1:DataGridView1.Rows.Add();
    DataGridView1["列名1", DataGridView1.Rows-1].value = 值;
    DataGridView1["列名2", DataGridView1.Rows-1].value = 值;
    //...N列2:DataGridViewRow rowNew = new DataGridViewRow();
    rowNew.CreateCells(DataGridView1);
    rowNew.Cells[列索引1].value = 值;
    rowNew.Cells[列索引2].value = 值;
    //...N列
    DataGridView.Rows.Add(rowNew);
      

  3.   

    使用DataTable绑定到DataGridView 的DataSource.
    然后 操作DataTable的Rows可以简单的动态添加删除