-->

Monday, November 9, 2015

How to get cell value from dataGridView in windows form c#

How to get cell value from dataGridView in windows form c#

In this article, I will teach you, How to get cell value from dataGridView in windows form c#. First of all bind the dataGridView with any Data Source then you can access cell value from it. I bind it with many data source, check this link. In previous article, I get the cell value from selected row of  dataGrid but on this time, we set the default row. In this article, I will give an example of cell click event.


private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
     
            decimal accno = Convert.ToDecimal(dataGridView1.Rows[e.RowIndex].Cells[0].Value);
            MessageBox.Show(accno.ToString());
}

Here, Cells[0] return the first column's cell value from dataGridView.

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved