简体   繁体   中英

Catch DataGridView Cell value on editing

How can I catch value Cell in DataGridView when user editing this cell?

I would validate on "real-time" input text.

You can use CellEndEdit event for DataGridView .

添加CellEndEdit事件

Then you can access cell value using following code

((DataGridView)sender).Rows[e.RowIndex].Cells[e.ColumnIndex].Value

I just displayed data in the cell in messagebox. Code will look like:

 private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
    {
        MessageBox.Show(((DataGridView)sender).Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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