;int intRowHandle = e.FocusedRowHandle; object rowIdObj = gridView1.GetRowCellValue(intRowHandle, "id"); if (DBNull.Value != rowIdObj)//做个判断否则获取不到id后报错 { FocusedRow_id = Convert.ToInt32(rowIdObj); } } view plaincopy to clipboardprint?//焦点行的FocusedHandle为: FocuseRow_Handle = -999998; //获取焦点行的handle ColumnView newview = (ColumnView)gridControl_Gongzi.FocusedView; FocuseRow_Handle = newview.FocusedRowHandle; //回车添加新行 private void gridView1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { ColumnView view = (ColumnView)gridControl_Gongzi.FocusedView; if(view.IsLastRow) { if (FocuseRow_Handle == 0) { gridView1.AddNewRow(); ColumnView newview = (ColumnView)gridControl_Gongzi.FocusedView; newview.FocusedColumn = newview.Columns["bumen"];//定位焦点网格的位置 FocuseRow_Handle = newview.FocusedRowHandle;//获取新焦点行的FocuseRowHandle 并初始化全局变量FocuseRow_Handle供保存操作时判断是update还是insert } 关于关于XtraGrid的使用的其他问题欢迎到编程论坛交流。