VB.NET Datagridview - 修改currentcell [英] VB.NET Datagridview - Modify currentcell

查看:73
本文介绍了VB.NET Datagridview - 修改currentcell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次提出一个问题,我会尽量明确。
我在vb.net中创建了一个包含3列和5行的datagridview。
我的列包含作业标题。每行包含有关这些作业的信息:名字,姓氏,社团,电话号码,邮件。

This is the first time I ask a question, I'll try to be clear. I created a datagridview in vb.net which contains 3 columns and 5 rows. My columns contains job headers. Each row contain information about these jobs : the firstname, lastname, society, phone number, mail.

它看起来像:

             | J1 | J2 | J3
----------------------------
firstname    | x  | y  | z
lastname     | x1 | y1 | z1
society      | x2 | y2 | z2
phone number | x3 | y3 | z3
mail         | x4 | y4 | z4

当我编辑作业1(x)的第一个名字时,我想输入此工作的姓氏单元格(x1)通过按Tab键。
目前,当我按Tab时,我输入第二个作业(y)的第一个名称的单元格。

When i edit the firstname of the job 1 (x), i would like to enter to the lastname's cell of this job (x1) by pressing tab. Currently, when i press tab, i enter in the firstname's cell of the second job (y).

我在datagridview之后尝试更改当前单元格。 CellEndEdit事件。我注意到选择单元格(x1),但是选项卡键将我编辑的当前单元格更改为普通currentcell(y)。

I tried to change the currentcell after the datagridview.CellEndEdit event. I noticed that the cell (x1) is selected, but the tab key change my edited currentcell to the 'ordinary currentcell' (y).

我如何防止选项卡改变我编辑的当前单元格的关键?
谢谢。

How can i prevent the tab key to change my edited currentcell ? Thanks.

推荐答案

尝试创建自己的DataGridView控件,以便覆盖ProcessCmdKey操作:

Try creating your own DataGridView control so you can override the ProcessCmdKey operation:

Public Class DataGridViewEx
  Inherits DataGridView

  Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean
    If keyData = Keys.Tab Then
      Me.ProcessDownKey(keyData)
      Return True
    End If
    Return MyBase.ProcessCmdKey(msg, keyData)
  End Function
End Class

这篇关于VB.NET Datagridview - 修改currentcell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆