C#中datagridview单元格跳转问题
我现在在keydown事件是写了代码,跳转到当前行的某个单元格,但是运行之后,跳转的是下一行的某个单元格,不知道是为什么?
if (this.dgvyzlr.Rows[rowid].Cells["ischild"].Value.Equals("1")) { //如果是子医嘱,则跳过用法,频率,直接跳到实际用量 this.dgvyzlr.CurrentCell = this.dgvyzlr.Rows[rowid].Cells["shijiyongliang"]; this.dgvyzlr.Rows[rowid].Cells["yongfa"].ReadOnly = true; this.dgvyzlr.Rows[rowid].Cells["pinlv"].ReadOnly = true; } else { if (this.cblrfs.Text.Equals("自由录入")) { //规格获得焦点 this.dgvyzlr.CurrentCell = this.dgvyzlr.Rows[rowid].Cells["guige"]; this.dgvyzlr.Rows[rowid].Cells["guige"].ReadOnly = false; } else if (this.cblrfs.Text.Equals("临床项目")) { //用法获得焦点 this.dgvyzlr.CurrentCell = this.dgvyzlr.Rows[rowid].Cells["yongfa"]; this.dgvyzlr.Rows[rowid].Cells["yongfa"].ReadOnly = false; } } this.dgvyzlr.Rows[rowid].Cells["yizhuneirong"].Value = this.dgvypxm.Rows[index].Cells["ypmingcheng"].Value.ToString();//医嘱内容 this.price = double.Parse(this.dgvypxm.Rows[index].Cells["ypdanjia"].Value.ToString());//单价 this.dgvyzlr.Rows[rowid].Cells["yizhuneirong"].Tag = this.dgvypxm.Rows[index].Cells["ypdanjia"].Value.ToString(); this.dgvyzlr.Rows[rowid].Cells["guige"].Value = this.dgvypxm.Rows[index].Cells["ypguige"].Value.ToString();//规格 this.dgvyzlr.Rows[rowid].Cells["yongliangdw"].Value = this.dgvypxm.Rows[index].Cells["ypyongliangdw"].Value.ToString();//用量单位 this.dgvyzlr.Rows[rowid].Cells["danwei"].Value = this.dgvypxm.Rows[index].Cells["ypdanwei"].Value.ToString();//单位 this.dgvyzlr.Rows[rowid].Cells["yaopinfenlei"].Value = this.dgvypxm.Rows[index].Cells["ypsx"].Value.ToString();//药品分类 this.dgvyzlr.Rows[rowid].Cells["ypbh"].Value = this.dgvypxm.Rows[index].Cells["ypbm"].Value.ToString();//药品编号 this.dgvyzlr.Rows[rowid].Cells["ydbh"].Value = this.dgvypxm.Rows[index].Cells["ypyaodian"].Value.ToString();//药典编号 jlxs = float.Parse(this.dgvypxm.Rows[index].Cells["jl_xs"].Value.ToString());//剂量 this.dgvyzlr.Rows[rowid].Cells["lcxmbh"].Value = "000000"; #region 药房编号 string yfbh = czyfbh(this.dgvypxm.Rows[0].Cells["ypyaofangmc"].Value.ToString()); this.dgvyzlr.Rows[rowid].Cells["yfbh"].Value = yfbh; #endregion heji(); this.dgvyzlr.BeginEdit(true); this.pnypxm.Visible = false;