datagridview1.rows.add提供了4种方法,在委托的时候使用Add(DataGridViewRow),就可以成功委托添加了。

之前用Add(Object[])委托但总是不行,抛出异常:参数计数不匹配。可能使用方法不对吧。

委托方法:
delegate int AddGridROW(DataGridViewRow i);//线程访问控件的委托,新建委托
DataGridViewRow dgvr = new DataGridViewRow();//实例化对象
dgvr.CreateCells(DataGridView1);//设置模板,映射作用
dgvr.Cells[0].Value = "这是第一列的值";
dgvr.Cells[1].Value = "这是第二列的值";
DataGridView1.Invoke(new AddGridROW(d_g_v.Rows.Add),dgvr);//委托

相关文章:

  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
  • 2021-09-17
  • 2022-02-27
  • 2021-05-25
  • 2021-10-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案