PDA开发中,你会发现DataGrid中的方法属性少得可怜,很多在datagridview能够实现的东西,在PDA中都不好实现。
往往我们使用DataGridView时并没有进行数据源的绑定,而是我们手动的对DataGridView中的数据进行操作,如:
添加:DataGridView.Rows.add("1","aaa","bbb");
修改:DataGridView.Rows[0].Cell[0].Value="2";
删除:DataGridView.Rows.RemoveAt(1);
添加:DataGridView.Rows.add("1","aaa","bbb");
修改:DataGridView.Rows[0].Cell[0].Value="2";
删除:DataGridView.Rows.RemoveAt(1);
但在PDA开发中,DataGrid中并没有Rows这个方法,并且DataGrid[0][0]也不能进行赋值,但我们可以通过绑定数据源,要对数据操作时,不对DataGrid进行操作,而是直接对数据源进行操作,如:在DataSet建立一个要显示的表,把表绑定到DataGrid中,操作如:
添加:dataSet1.表名.Rows.Add("","");
修改:dataSet1.表名.Rows[dataGrid1.CurrentRowIndex][1] = "bb";
删除:dataSet1.表名.Rows.RemoveAt(1)
添加:dataSet1.表名.Rows.Add("","");
修改:dataSet1.表名.Rows[dataGrid1.CurrentRowIndex][1] = "bb";
删除:dataSet1.表名.Rows.RemoveAt(1)
获取单元格的location可以使用DataGrid.GetCellBounds(0,0).Location