Pages

Friday, 5 August 2011

Get or Set Value of Selected Field in DataGridView in C Sharp (C#) WinForms



1. Get Value of Selected Field in DataGridView.

in this example i am using a MessageBox to Show the selected fields value.

MessageBox.Show(dataGridView1.CurrentCell.Value.ToString());

1. Set Value to Selected Field in DataGridView.

You can set both string and int to the field.


// setting string value
dataGridView1.CurrentCell.Value = 101;

// setting string value
dataGridView1.CurrentCell.Value = "C Sharp-Language";

0 comments:

Post a Comment