导航

方法1:添加新行

 if(dgFunction.CanFocus)
   {
    dgFunction.BindingContext[dgFunction.DataSource,dgFunction.DataMember].AddNew();
    dgFunction.Focus();
   }

方法2:使用对 Windows 窗体上绑定到相同数据源的数据绑定控件进行同步

if(dgFunction.CanFocus)
   {
    BindingManagerBase bm = BindingContext[ds,"Version.versionAndFun"];
    if (bm != null)
    {
     DataGridCell cell = new DataGridCell(bm.Count, 0);
     dgFunction.CurrentCell = cell;
    }
   }