Reputation: 375
I have Gridview with several columns. When I select particular row of gridview, I am not able to get the value of first cell. Its showing following error.
Error 15 'System.Windows.Forms.DataGridView' does not contain a definition for 'Cells' and no extension method 'Cells' accepting a first argument of type 'System.Windows.Forms.DataGridView' could be found (are you missing a using directive or an assembly reference?)
Upvotes: 0
Views: 1162
Reputation: 125197
Mihai Caracostea Showed your problem correctly.
Just to learn how to work with selected row(s) please consider these notes:
MultiSelect
yo false
yourGrid.SelectedRows.Count==1
if you want to check if there is a selected rowyourGrid.SelectedRows[0].Cells[index of column]
or yourGrid.SelectedRows[0].Cells[nam of column]
Upvotes: 1
Reputation: 8466
You must do
foreach (DataGridViewRow row in ... )
You have a wrong type in your iteration variable.
Upvotes: 3