Hello,

To get values from selected row we use :

X = dataGridView1[Column,Row].Value;

X needs to be the variable of the same type as value of the cell in the grid.

If you want to know what is the number of row that you have selected use this :

int Row = dataGridView1.CurrentRow.Index;

Number of column in the row starts from zero, so if you have three columns :

int X1 = 0;
int X2 = 0;
int X3 = 0;
int Row = 0;
Row = dataGridView1.CurrentRow.Index;
X1 = dataGridView1[0,Row].Value;
X2 = dataGridView1[1,Row].Value;
X3 = dataGridView1[2,Row].Value;
MessageBox.Show("Values in the " + Row.ToString() + ". row : " + X1.ToString()+
" " + X2.ToString() + " " + X3.ToString(), "Values");

If you would like to know many more things about DataGridView control use this link :

DataGridView MSDN Library[

^]

All the best

Perić Željko