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

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

问题描述

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



我曾经有过在有 CellClick 处理程序的代码 DataGridViewCellEventArgs 作为参数,所以我能够从事件参数的参数,但 CurrentCellChanged 事件具有 EventArgs的因为我相信这是应该意味着世界上没有数据,此事件的参数。



是否有访问新的当前所选单元格的列索引?


解决方案

使用 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


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.

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?

解决方案

Use DataGridView.CurrentCell property ..

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天全站免登陆