How to get cell values out of a selected row in a DataGrid using

Apr 1, 2009 at 8:55 PM
I need to know how to get all of the values out of a selected row in a datagrid? example would be great!  I would like to loop through each cell in a selected row, grab each value and its corresponding column name, and store both values.  Here is what I have so far... I'm not sure how to access each cell's content.


dg As DataGrid



Dim intCounter, intRowIndex, intNumColumns As Integer



'Retrieves the selected row's Index which is zero based.


dg = dgResults

intRowIndex = dg.SelectedIndex

intNumColumns = dgResults.Columns.Count


"The Row's Number:" & " " & Convert.ToString(intRowIndex) & " " & "The # of Columns" & " " & Convert.ToString(intNumColumns))



Do While intCounter <= intNumColumns


intCounter += 1




Apr 6, 2009 at 9:38 AM


i dont know well, but this is how i get by c#

 private void dataGVReport_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
DataGridRow dgRow = e.Row;
DataRowView rowView = dgRow.Item as DataRowView;

  this rowView contains the current selected row


Apr 6, 2009 at 8:33 PM
Excellent!  Works perfect.  However, I need to use  DataGridRow dgRow = e.Row; and DataRowView rowView = dgRow.Item as DataRowView; in a procedure which is called by a button.  Any ideas?