Start New Discussion within our Software Development Community

How to access all values of the selected Row of a DatagridView in C# using Coding, MS Access as a Database..??

You would like to get all the values from a dgv`s row?

Lets say you want to get data from 5th row (dgv has 3 columns):

string = column1 = dgv[0,6].Value.ToString();
string = column2 = dgv[1,6].Value.ToString();
string = column3 = dgv[2,6].Value.ToString();

If the column has a default type of string, no need to parse to stirng on the end.
Same goes for columns of type int, boolean, dateTime....
If the column is type of int you simple do:

int column1 = dgv[0,6].Value;//no need to convert

Mitja

ups, sorry, and thx for reminding me. I has to be this way:

string column1 = dgv[0,6].Value.ToString();
string column2 = dgv[1,6].Value.ToString();
string column3 = dgv[2,6].Value.ToString();
This article has been dead for over six months. Start a new discussion instead.