如何在datagridview c#中输入事件 [英] how to make enter event in datagridview c#
本文介绍了如何在datagridview c#中输入事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含10行和10列的datagridview,我希望当我在第一个单元格中输入一些值时,相同列的所有单元格将显示相同的值
请帮我解决这个问题。
I have a datagridview with 10 Rows and 10 columns, I want when I enter some value on first cell then all cells of same column will show the same value
Pls help me on this.
推荐答案
DataGridView 体育 CellEnter事件。订阅一个方法,使用它的参数(承载行和列)以识别引发事件的单元格并采取相应的行动。
DataGridView sports the CellEnter event. Subscribe a method to it, use its arguments (bearing row and column) to identify the cell that raised the event and act accordingly.
嗨TusharZoo,
我假设您没有将网格值绑定到数据源?
所以你可以只处理GridView的CellEndEdit
事件,然后运行你想要的任何逻辑(更改显示的值或底层数据源)
Hi TusharZoo,
I assume you have not bound your grid values to a data source?
So you could just handle GridView'sCellEndEdit
Event and than run whatever logic you want (Change the displayed values or the underlaying data source)
dataGridView1.CellEndEdit += dataGridView1_CellEndEdit;
...
void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
var cell = dataGridView1[e.ColumnIndex, e.RowIndex];
cell.Value...
}
}
这篇关于如何在datagridview c#中输入事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文