Hi,
Use the datatables default view to return right datarow. Quick
example.
Dim ds As New DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim strConn As String
Dim strSQL As String
Dim da As OleDbDataAdapter
Dim conn As OleDbConnection
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = Northwind.mdb;"
conn = New OleDbConnection(strConn)
da = New OleDbDataAdapter("Select * From Categories", conn)
da.Fill(ds, "Categories")
DataGrid1.DataSource = ds.Tables("Categories")
End Sub
Private Sub Form1_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.DoubleClick
Dim cm As CurrencyManager = CType(Me.BindingContext(DataGrid1.DataSource),
CurrencyManager)
Dim drv As DataRowView
drv = ds.Tables("Categories").DefaultView.Item(cm.Position)
MessageBox.Show(drv.Item("CategoryName").ToString)
End Sub
Disable sort on grid
Set the datagrids or tablestyle if you added one Allowsorting to false
http://msdn.microsoft.com/library/d...sdatagridtablestyleclassallowsortingtopic.asp
Ken
---------------------------
I found that rows in datagrid can be sorted by clicking on the column
header. However, this doesn't refresh the .currentindex
DataGrid1.CurrentCell.RowNumber
I need either to disable colum sorting programmatcially or somehow refresh
the DataGrid1.CurrentCell.RowNumber index so that it will reflect the
correct rownumber.
Any help is greatly appreciated!
Bill