如何使用c#.net将焦点设置到gridview中的特定列 [英] how to set focus to specific column in gridview using c#.net

查看:310
本文介绍了如何使用c#.net将焦点设置到gridview中的特定列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Windows窗体应用程序中使用c#.net将焦点设置为网格视图中的特定列

how to set focus to specific column in grid view using c#.net for windows form applications

推荐答案

例如,在这里,我尝试将焦点设置为基于当前单元格的下一个单元格

for example here i''m try to set focus to next cell based on current cell

int columnIndex = dataGridView.CurrentCell.ColumnIndex;
int rowIndex = dataGridView.CurrentCell.RowIndex;

// here you may need to check current column is not the last on 
SetFocus(rowIndex , columnInde+1 );



您可以将焦点设置如下



you can set focus as below

public void SetFocus(int row, int column)

{
  datagridview.Focus();
  datagridview.CurrentCell = datagridview.Rows[row].Cells[column];
}


这篇关于如何使用c#.net将焦点设置到gridview中的特定列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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