简体   繁体   English

加载页面时,将焦点放在gridview中第8列的单元格上

[英]give focus to a cell of 8 th column of in gridview when loading of page

I am using VS 2005,asp.net,c#.net. 我正在使用VS 2005,asp.net,c#.net。 I have a grid view which is in an update panel. 我在更新面板中有一个网格视图。 How to give focus to a cell of 8 th column in grid view when loading of page? 加载页面时如何在网格视图的第8列单元格中赋予焦点?

Thanks in advance George. 预先感谢乔治。

First of all, there is no focus on a cell. 首先,没有关注单元格。 Focus is always a keyboard focus; 焦点始终是键盘焦点; this is the attribute of a control, not any of its parts. 这是控件的属性,而不是控件的任何部分。 What you need is selection, which is not related to focus. 您需要的是选择,它与焦点无关。

Also, the result of selection depends on selection style of your DataGridView. 此外,选择的结果取决于DataGridView的选择样式。 to select a specific cell you can use this code. 选择一个特定的单元格,您可以使用此代码。

this.dataGridView1.SelectionMode = DataGridViewSelectionMode.CellSelect;
dataGridView1.MultiSelect = false;

尝试这个

datagridview1.CurrentCell = datagridview1[8,0];//replace 0 with row index of datagridview

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM