在DataGridView CurrentCellChanged事件中获取当前单元格列索引 [英] Get current cell column index in DataGridView CurrentCellChanged Event

查看:126
本文介绍了在DataGridView CurrentCellChanged事件中获取当前单元格列索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 DataGridView CurrentCellChanged 事件处理程序,我想要能够访问当前选定的单元格来自事件处理程序的列索引。

I have the CurrentCellChanged event handler of a DataGridView and i want to be able to access the current selected cells column index from the event handler.

我曾经在 CellClick 处理程序中具有 DataGridViewCellEventArgs 作为一个参数,所以我能够从事件args参数获取列索引,但$ code> CurrentCellChanged 事件有 EventArgs 作为参数,我认为这意味着这个事件没有数据。

I used to have the code in the CellClick handler which has DataGridViewCellEventArgs as a parameter so i was able to get the column index from the event args parameter but the CurrentCellChanged event has EventArgs as parameters which i believe is supposed to imply that theres no data for this event.

有没有办法访问新的当前选定的单元格列索引?

Is there a way to access the new currently selected cells column index?

推荐答案

使用 DataGridView.CurrentCell 属性..

http://msdn.microsoft.com/en-us/library/system.windows.forms。 datagridview.currentcell.aspx

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

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.aspx

这篇关于在DataGridView CurrentCellChanged事件中获取当前单元格列索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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