问题:将datagrid光标移动到指定的列 [英] Problem:moving datagrid cursor to specified column

查看:110
本文介绍了问题:将datagrid光标移动到指定的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我在将datagrid光标聚焦在指定列时遇到问题.
我的以下代码运行良好
DataGridView1.CurrentCell = DataGridView1.Item(2, 0)
这意味着当我单击标有GOTO的按钮时,datagrid中的光标将移至datagrid中的第三列.但是当我使用以下代码时
DataGridView1.CurrentCell = DataGridView1.Item("CompanyName", 0)
我收到逻辑错误,提示未找到类似列名称"CompanyName"的内容.
但是当我检查使用CompanyName命名的访问文件列时,该名称存在.
我要去哪里错?

hi all,
i am having problem regarding focusing datagrid cursor at specified column.
my following code is doing fine
DataGridView1.CurrentCell = DataGridView1.Item(2, 0)
which means that when i click on button labeled GOTO then cursor in datagrid moves to 3rd column in datagrid. but when i use the following code
DataGridView1.CurrentCell = DataGridView1.Item("CompanyName", 0)
i get an logicle error which says some thing like column name "CompanyName" not found.
but when i checked my access file column named with CompanyName exists.
where am i going wrong?
any kind of help will be deeply appreciated

推荐答案

使用DataGridView1.Columns(2).Name 检查显示的内容并使用该名称.
Check what it shows with DataGridView1.Columns(2).Name and use that name.


这篇关于问题:将datagrid光标移动到指定的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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