473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

find row in datagrid and move to it?

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
3 13549
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Steve B. | last post by:
How do I find the column (index) number at runtime of a particular DataGrid column if I know the column header string //somthing like the following int x = datagrid.column;
3
by: Rob | last post by:
You can find datagrid in page by refering the form. Gatagrid is a child control of Form. Here is the code ----------------- Dim ctl As New Control For Each ctl In...
3
by: RJN | last post by:
Hi I need to find the datagrid height dynamically based on the no. of records in the grid. I have set the height for the Item style and alternating item style. But I can not depend on this since...
5
by: Ed Chiu | last post by:
Hi, Is there a way to sort a datagrid without the help of SQL server? I usually use ADO.Net to get a dataset from SQL sever then bind it to datagrid. Now I am asked to make datagrid support...
1
by: Simon Abolnar | last post by:
I have a table fixed width (758px), centered. Inside a table there is datagrid of fixed width (752px). If I open web page at full screen, everything is OK. If I resize window, table and datagrid...
1
by: Irfan | last post by:
hi, all In VB 2005 Beta i cant find dataGrid control in the toolbox, instead DataGridView is available. What is the differance between the two ? How can i get dataGrid Control? Thanks
7
by: Mrozu | last post by:
Hi I have datagrid, with 2 columns Id and Name. I want, then i insert to datagrid, to column name "d", datagrid move to record where value of name is "d_____" , when i insert to name "da", move...
0
by: fia | last post by:
Hi I have made my DataGrid move to the next cell on TAB and Enter (the code below) and it works fine, but when standing in the first cell on the new row (last row) and pressing TAB or Enter the...
0
by: Matt | last post by:
Ok, given that this is a windows ocx, it should be pretty easy to do this but I just haven't been able to figure it out. What I have is a datagrid on my form populated with various pieces of...
8
by: inFocus | last post by:
Hello, I am new to python and wanted to write something for myself where after inputing two words it would search entire drive and when finding both names in files name would either copy or move...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.