请问在datagridview中怎么样才能设置编辑的焦点

zhiweixuexi8 2015-04-29 12:27:58
我在grid_CellEndEdit事件中 执行完该事件代码后 我想让当前单元格继续保持编辑状态应该怎么样弄?在这个事件中我使用了GridWJLR[e.ColumnIndex, e.RowIndex].Selected = true;
GridWJLR.CurrentCell = GridWJLR[e.ColumnIndex, e.RowIndex];
GridWJLR.BeginEdit(false);

都没有效果。每次编辑后点回车下面那行就空白了,调试查看e.RowIndex跑到下面这行了。请问该怎么样弄才能继续让当前单元格保持编辑状态?
...全文
160 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhiweixuexi8 2015-05-02
  • 打赏
  • 举报
回复
问题是我不用回车离开当前的编辑事件,我用鼠标点击其他单元格,那么其他单元格也是变白了而没有让让先之前编辑的单元格回到编辑状态并且焦点于该单元格。
道玄希言 2015-04-29
  • 打赏
  • 举报
回复
按下Enter键达到与按下Tab键的效果 class myDataGridView : DataGridView { protected override bool ProcessDialogKey(Keys keyData) { if (keyData == Keys.Enter) { int col = this.CurrentCell.ColumnIndex; int row = this.CurrentCell.RowIndex; if (row != this.NewRowIndex) { if (col == (this.Columns.Count - 1)) { col = -1; row++; } this.CurrentCell = this[col + 1, row]; } return true; } return base.ProcessDialogKey(keyData); } protected override void OnKeyDown(KeyEventArgs e) { if (e.KeyData == Keys.Enter) { int col = this.CurrentCell.ColumnIndex; int row = this.CurrentCell.RowIndex; if (row != this.NewRowIndex) { if (col == (this.Columns.Count - 1)) { col = -1; row++; } this.CurrentCell = this[col + 1, row]; } e.Handled = true; } base.OnKeyDown(e); } } 运用: this.dataGridView1 = new myDataGridView();
zhiweixuexi8 2015-04-29
  • 打赏
  • 举报
回复
有人遇到过这种问题么?
zhiweixuexi8 2015-04-29
  • 打赏
  • 举报
回复
顶下................

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧