Click here to Skip to main content
15,921,156 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a dataGridView table and I want to retrieve the cell from the fourth column of the selected row. For example if I have a table with the following headings:

First Name, Last Name, Address

I want to select the tenth row and retrieve whats in the cell under address. Is there an easy way to do this please.
Posted

1 solution

Use the DataGridView's CurrentCell property?
An example from MSDN:
this.dataGridView1.CurrentCell = this.dataGridView1[1,0];
 
Share this answer
 
v2
Comments
Neil Cross 19-Oct-10 10:51am    
I investigated the CurrentCell property but I must have missed something. Could you give me an example please. I've never used dataGrids before so I'm learning everything from scratch.
Marc A. Brown 19-Oct-10 11:04am    
If you're looking to get the value at that position, it appears you could just use dataGridView1[4, 10] if you want the value at the cell in the fourth column, tenth row. If you're looking to set that cell as the current cell instead, you'd do it as in my example above in the answer, substituting the row and column you want for the 1 and 0.
Marc A. Brown 19-Oct-10 11:17am    
Don't forget to accept the answer if, when all is said and done, it gives you what you needed.
Neil Cross 20-Oct-10 12:11pm    
Thanks that exactly what I needed, sorry for the slow response.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900