find row in datagrid and move to it?

R

Rich

Hello,

If my datagrid is based on a dataTable (t1) and the
currency manager is also bound to t1 and I do a find on a
key
dim dRow As DataRow, t1 As DataTable
....
dRow = t1.Rows.find(somekey)
If Not dRow Is Nothing

how can I move the currency manager to this row?

Thanks,
Rich
 
R

Rich

Thank you for the example. It worked great (although I
had to modify it a little bit cause using Sql Server). I
am just starting out with VB.net (stepping up from com
VB). Anyway, I haven't worked with dataviews yet. So
this example was nice because that is next. But I did
come up with a kludgy sort of solution for the datagrid.
I hope maybe you could explain about var.GetType. GetType
is confusing me. Here is the solution I came up with:

Dim dRow As DataRow, ddRow() As DataRow
Dim t1 As DataTable, , str1 As Object
Dim i As Integer, j As Integer, k As Integer

t1 = ds3.Tables("Contacts")
j = 27 '--->hardoce a value that I know is there
dRow = t1.Rows.Find(27)
If Not dRow Is Nothing Then
ddRow = t1.Select()
For i = 0 To ddRow.GetUpperBound(0)
str1 = ddRow(i)(0)
k = CType(str1, Integer)
If k = j Then
cma.Position = i
drg1.Select(drg1.CurrentRowIndex)
Exit For
End If
Next
End If

So if my dataRow (dRow) is not Nothing then I set up a
dataRow array ddRow() and loop through that. The real
kludgy part is that when ddRow(i)(0) = 27 I don't know how
to compare it to j (an Integer). So I set up an object
(str1) to this value, and the only way I could come up
with to extract the value was to set up another Integer, k
as above. How else could I compare the value stored in
ddRow(i)(0) to j?

Thanks again for your reply,
Rich
 
R

Rich

Well, I think I figured out what var.GetType is about.
When you get that option I think it means

var2 = CType(var1, varType)

or

Console.Writeline(CType(var1, Integer)) for example.

Little by little I'm getting it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top