1.11M Members

Access Vale Selected Row in DataGridview in C#

 
0
 

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

 
0
 

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

 
0
 

There is a typo in your first code block. Don't put '=' between string and the variable names :)

 
0
 

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();
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: