以编程方式将记录指针设置在C#DataGridView中 [英] Programmatically setting the record pointer in a C# DataGridView

查看:112
本文介绍了以编程方式将记录指针设置在C#DataGridView中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以编程方式将记录指针设置在C#DataGridView中?

How do I programmatically set the record pointer in a C# DataGridView?

我尝试过DataGridView.Rows [DesiredRowIndex] .Selected = true;,这不起作用。它所做的是突出显示网格中的行;它不会将记录指针移动到该行。

I've tried "DataGridView.Rows[DesiredRowIndex].Selected=true;", and that does not work. All it does is highlight that row within the grid; it doesn not move the record pointer to that row.

推荐答案

要更改datagrid的活动行,您需要设置当前数据网格的单元格属性到您选择的行上的非隐藏的非禁用的非标题单元格。你会这样做:

To change the active row for the datagrid you need to set the current cell property of the datagrid to a non-hidden non-disabled, non-header cell on the row that you have selected. You'd do this like:

dataGridView1.CurrentCell = this.dataGridView1[YourColumn,YourRow];

确保单元符合上述条件。有关更多信息,请访问:

Making sure that the cell matches the above criteria. Further information can be found at:

http://msdn.microsoft.com/en-us/library/yc4fsbf5.aspx

这篇关于以编程方式将记录指针设置在C#DataGridView中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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