检查Datagrid Cell [英] check Datagrid Cell

查看:87
本文介绍了检查Datagrid Cell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我检查数据网格上的当前单元格有问题。我的目标是每当数据网格上的按Tab键时在数据网格的当前单元格上做一个检查器。但我在这里的代码有困难。



继承人我的代码:



Hi there i have problem checking current cell on my datagrid. my goal was to make a checker on the current cell of the datagrid whenever a press tab on the datagrid. but im having difficulty on my code here.

heres my code:

Private Sub grdItems_KeyDown(sender As Object, e As KeyEventArgs) Handles grdItems.KeyDown
        
        Dim a, b As Integer 

        If e.KeyCode = Keys.Tab Then
            a = Me.grdItems.CurrentCell.ColumnIndex
            b = Me.grdItems.CurrentCell.RowIndex

            If Me.grdItems.CurrentCell = Me.grdItems(a, b) Then
                MessageBox.Show("next row")
            End If
        End If
    End Sub





但是每当我查看datagrid单元格时我都会得到一个...抱歉我的英文不好..在此先感谢..:)



but im just getting an whenever i check datagrid cell.. sorry for my bad english.. thanks in advance.. :)

推荐答案

获取DataGridViewItems的集合(我希望你的' grdItems '是标准的 DataGridView ???)你必须使用 grdItems.Items()。但是如果你设置 a (' ColumnIndex ')和 b (' RowIndex ')与CurrentCell的Col-和Row-索引相同,您的
To get a collection of DataGridViewItems (I hope your 'grdItems' is standard DataGridView???) you have to use grdItems.Items(). But if you set a('ColumnIndex') and b('RowIndex') the same as CurrentCell's Col- and Row- indexes, your
Me.grdItems.CurrentCell = Me.grdItems.Items(a, b)

始终 True 。每次 你会得到一个 MsgBox

我不明白你的项目是做什么的,但它似乎我是你的意思是一个独立的'CurrentCell', ColumnIndex RowIndex 是预定义的变量。当用户移动 DataGridViewItem 的集合(使用'Tab'键)时,您想要捕获'CurrentCell'的坐标是否与<$ c的坐标相同$ c> grdItems.CurrentCell 。

对吗?..但是为了什么?

DataGridView 提供了许多有用的事件,属性和方法,允许您处理不同类型的单元格,它们的装饰和值。

will always True. And everytime you will get a MsgBox.
I don't understand what your project does, but it seems to me that you mean an independent 'CurrentCell' which ColumnIndex and RowIndex are predefined variables. And when user moves through a collection of DataGridViewItem (using 'Tab' key), you want to catch if coordinates of your 'CurrentCell' will the same as coordinates of grdItems.CurrentCell.
Right?.. But what for?
DataGridView offers a lot of useful events, properties and methods that allow you to work with different types of cells, their decoration and values.


' Try this code .....


Dim x As Integer
Dim y As Integer
x = Me.FadingGridView.CurrentCell.RowIndex
y = Me.FadingGridView.CurrentCell.ColumnIndex
If e.KeyCode = Keys.Tab Then
    If FadingGridView.Rows(x).Cells(0).Selected = True Then
        Me.FadingGridView.CurrentCell = Me.FadingGridView(x, y)
    End If
End If


谢谢你先生寻求解决方案..但我无法得到它..呵呵..我的目标是任何方式,例如我的数据网格上有条形码列和产品列。每当我按下enter键时,无论何时我都在条形码列上,应该关注的单元格是产品列。但焦点只是转到另一个条形码列,这是一个新行。我只想把我的重点放在产品专栏上..



继承我的代码..





thank you sir for the solution.. but i could not get it though.. hehe.. any way my goal was for example i have a barcode column and product column on my datagrid. whenever i am on barcode column whenever i press enter, the cell that should be on focus was the product column. but the focus just go to another barcode column which is a new row again. i just want my focus to be on the product column..

heres my code..


Private Sub grdItems_KeyDown(sender As Object, e As KeyEventArgs) Handles grdItems.KeyDown
        
        Dim x As Integer

        'GET DATAGRID ROW AND COLUMN INDEX
        x = Me.grdItems.CurrentCell.RowIndex

       

        'THIS IS FOR RETURN FUNCTION
        If e.KeyCode = Keys.Return Then
            If grdItems.Rows(x).Cells(0).Selected = True Then
                Me.grdItems.CurrentCell = Me.grdItems(x, 1)
            End If
        End If
    End Sub





i也尝试了你的代码,但它不会去到了我想要关注的目标。帮助请...提前感谢..



i have also tried your code but it just wont go to what i wanted the focus to go to. help pls.. thanks in advance..


这篇关于检查Datagrid Cell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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