DEV GridView新增一条数据问题 5C

图片说明DEV GridView后台绑定数据,当点击行排序,然后新增一行,都会变成从上面插入,怎么才能一直从下面新增呢?

后台新增代码:
private void bar_Create_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
string fyxmid = xtraTabControl1.TabPages[xtraTabControl1.SelectedTabPageIndex].Name.ToString();
Control GridControl1 = xtraTabControl1.TabPages[xtraTabControl1.SelectedTabPageIndex].Controls[0];
GridControl x = (GridControl)GridControl1;
DataTable dt = x.DataSource as DataTable;
DataRow NewRow = dt.NewRow();
NewRow["FLAG"] = "0";
NewRow["ID"] = fyxmid;
dt.Rows.Add(NewRow);
BaseView view = x.MainView;
GridView gridView1 = (GridView)view;
gridView1.RefreshData();//刷新数据
gridView1.FocusedRowHandle = gridView1.RowCount - 1;
SetButtonEnable(edit);
}

3个回答

sinat_33460472
哆啦CMeng this.GridV_M.FocusedRowHandle = this.GridV_M.DataRowCount - 1;//焦点转移到最后一行 BaseTabPage.SelectedTabPage = this.CardPage; 麻烦问一下第二句:BaseTabPage.SelectedTabPage = this.CardPage;是什么意思呢,没搜到。
大约 2 年之前 回复

this.GridV_M.FocusedRowHandle = this.GridV_M.DataRowCount - 1;//焦点转移到最后一行

BaseTabPage.SelectedTabPage = this.CardPage;
麻烦问一下第二句:BaseTabPage.SelectedTabPage = this.CardPage;是什么意思呢,没搜到。

在初始化函数加入以下代码:
gridView1.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom;//自动在末尾添加新建行

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问