Search code examples
c#datagridviewmessagebox

How to get DataGridView cell value in messagebox?


How can I get DataGridView cell value to be written in the MessageBox in C#?


Solution

  • You can use the DataGridViewCell.Value Property to retrieve the value stored in a particular cell.

    So to retrieve the value of the 'first' selected Cell and display in a MessageBox, you can:

    MessageBox.Show(dataGridView1.SelectedCells[0].Value.ToString());
    

    The above probably isn't exactly what you need to do. If you provide more details we can provide better help.