By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,690 Members | 1,135 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,690 IT Pros & Developers. It's quick & easy.

find row in datagrid and move to it?

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

The dataview has a find method that returns the row number of a
sorted column. Use the currency manager to go to that row. If you need to
use a datatable you need to find the row number yourself. Here is a link to
an example that uses a dataview.
http://www.onteorasoftware.com/downl...taviewfind.zip

Ken
------------------

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:7a****************************@phx.gbl...
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

Nov 20 '05 #2

P: n/a
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
-----Original Message-----
Hi,

The dataview has a find method that returns the row number of asorted column. Use the currency manager to go to that row. If you need touse a datatable you need to find the row number yourself. Here is a link toan example that uses a dataview.
http://www.onteorasoftware.com/downl...taviewfind.zip

Ken
------------------

"Rich" <an*******@discussions.microsoft.com> wrote in messagenews:7a****************************@phx.gbl...
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

.

Nov 20 '05 #3

P: n/a
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.

-----Original Message-----
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. GetTypeis 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 howto 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, kas above. How else could I compare the value stored in
ddRow(i)(0) to j?

Thanks again for your reply,
Rich
-----Original Message-----
Hi,

The dataview has a find method that returns therow number of a
sorted column. Use the currency manager to go to that

row. If you need to
use a datatable you need to find the row number

yourself. Here is a link to
an example that uses a dataview.
http://www.onteorasoftware.com/downl...taviewfind.zip

Ken
------------------

"Rich" <an*******@discussions.microsoft.com> wrote in

message
news:7a****************************@phx.gbl...
Hello,

If my datagrid is based on a dataTable (t1) and the
currency manager is also bound to t1 and I do a find
ona 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

.

.

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.