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

Datagrid findfirst findnext

P: n/a
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find functionality.
With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in an
Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in that
it returns a valid row, but it is not the first row with that value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is not
the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured out
how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg
Nov 21 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
John,

I know that the dataview.find exist hower I did never use that one,
(probably because for that one the datarowcollection.find does(is) the same
and is easier to handle.

I think that you want more rows back and than the datarowfilter is easier to
handle.

The datarowfilter you set by (Keep in mind that the rowfilter is dynamicly
and reacts direct on the change of a filterfield) All is typed by hand in
this message so watch typos

\\\
dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
'SometingElse'"
//
(Mostly you have to make dynamicly a concatenated string, Think than to
enclose those in single quotes for string fields
\\\
For Each dvv As DataRowView In dv
dvv(0) = "Myfield"
Next
///
Or if you want that
\\\
For i as integer = 0 to dv.count-1
dv(i)(0) = "Myfield"
Next
///
I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find functionality.
With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in an
Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in that
it returns a valid row, but it is not the first row with that value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is not
the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured out
how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg

Nov 21 '05 #2

P: n/a
Cor,
Thanks for the response. I have seen your responses to these type of
questions before and I was hoping you would respond.

Unfortunately, though, the filter isn't really what I'm after. I really
would like to keep all of the data visible so that the user can scroll
around in curiosity if need be. If you have ever used the find in Access I
am trying to build something along that line. Where I can specify criteria
such as: search in one field, all fields, at the beginning of the field, end
of the field, must match the entire field, or case sensitive etc. I suspect
that I am going to have to iterate through each field of each row based on
the search criteria. I was hoping for a quicker method as this method will
be slow. My database currently has 30,000 records with 5 fields: ID,
Source, Song, Artist, Album.

I have tried the filter method, and it would work as a last resort, but
ultimately it isn't what I'm after. Any other suggestions?

John
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4*************@TK2MSFTNGP11.phx.gbl...
John,

I know that the dataview.find exist hower I did never use that one,
(probably because for that one the datarowcollection.find does(is) the
same and is easier to handle.

I think that you want more rows back and than the datarowfilter is easier
to handle.

The datarowfilter you set by (Keep in mind that the rowfilter is dynamicly
and reacts direct on the change of a filterfield) All is typed by hand in
this message so watch typos

\\\
dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
'SometingElse'"
//
(Mostly you have to make dynamicly a concatenated string, Think than to
enclose those in single quotes for string fields
\\\
For Each dvv As DataRowView In dv
dvv(0) = "Myfield"
Next
///
Or if you want that
\\\
For i as integer = 0 to dv.count-1
dv(i)(0) = "Myfield"
Next
///
I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find functionality.
With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in
an Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in
that it returns a valid row, but it is not the first row with that value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is
not the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured out
how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg


Nov 21 '05 #3

P: n/a
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a second
dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
..
Cor,
Thanks for the response. I have seen your responses to these type of
questions before and I was hoping you would respond.

Unfortunately, though, the filter isn't really what I'm after. I really
would like to keep all of the data visible so that the user can scroll
around in curiosity if need be. If you have ever used the find in Access
I am trying to build something along that line. Where I can specify
criteria such as: search in one field, all fields, at the beginning of the
field, end of the field, must match the entire field, or case sensitive
etc. I suspect that I am going to have to iterate through each field of
each row based on the search criteria. I was hoping for a quicker method
as this method will be slow. My database currently has 30,000 records
with 5 fields: ID, Source, Song, Artist, Album.

I have tried the filter method, and it would work as a last resort, but
ultimately it isn't what I'm after. Any other suggestions?

John
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4*************@TK2MSFTNGP11.phx.gbl...
John,

I know that the dataview.find exist hower I did never use that one,
(probably because for that one the datarowcollection.find does(is) the
same and is easier to handle.

I think that you want more rows back and than the datarowfilter is easier
to handle.

The datarowfilter you set by (Keep in mind that the rowfilter is
dynamicly and reacts direct on the change of a filterfield) All is typed
by hand in this message so watch typos

\\\
dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
'SometingElse'"
//
(Mostly you have to make dynamicly a concatenated string, Think than to
enclose those in single quotes for string fields
\\\
For Each dvv As DataRowView In dv
dvv(0) = "Myfield"
Next
///
Or if you want that
\\\
For i as integer = 0 to dv.count-1
dv(i)(0) = "Myfield"
Next
///
I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find
functionality. With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in
an Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in
that it returns a valid row, but it is not the first row with that
value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is
not the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured
out how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg



Nov 21 '05 #4

P: n/a
Cor,
So, If I understand you correctly, you are saying to create a second
dataview of the table, do my filter on it, find the record I need (which
will likely have to still be done by looping through the filtered records,
but at least far less of them), get the unique ID from the found record then
find that ID on the displayed dataview and move to that record. Is that
about right?

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a second
dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
.
Cor,
Thanks for the response. I have seen your responses to these type of
questions before and I was hoping you would respond.

Unfortunately, though, the filter isn't really what I'm after. I really
would like to keep all of the data visible so that the user can scroll
around in curiosity if need be. If you have ever used the find in Access
I am trying to build something along that line. Where I can specify
criteria such as: search in one field, all fields, at the beginning of
the field, end of the field, must match the entire field, or case
sensitive etc. I suspect that I am going to have to iterate through each
field of each row based on the search criteria. I was hoping for a
quicker method as this method will be slow. My database currently has
30,000 records with 5 fields: ID, Source, Song, Artist, Album.

I have tried the filter method, and it would work as a last resort, but
ultimately it isn't what I'm after. Any other suggestions?

John
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4*************@TK2MSFTNGP11.phx.gbl...
John,

I know that the dataview.find exist hower I did never use that one,
(probably because for that one the datarowcollection.find does(is) the
same and is easier to handle.

I think that you want more rows back and than the datarowfilter is
easier to handle.

The datarowfilter you set by (Keep in mind that the rowfilter is
dynamicly and reacts direct on the change of a filterfield) All is typed
by hand in this message so watch typos

\\\
dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
'SometingElse'"
//
(Mostly you have to make dynamicly a concatenated string, Think than to
enclose those in single quotes for string fields
\\\
For Each dvv As DataRowView In dv
dvv(0) = "Myfield"
Next
///
Or if you want that
\\\
For i as integer = 0 to dv.count-1
dv(i)(0) = "Myfield"
Next
///
I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find
functionality. With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in
an Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in
that it returns a valid row, but it is not the first row with that
value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is
not the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured
out how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg



Nov 21 '05 #5

P: n/a
John,

Seeing it again now I think that you are after this as the sample bellow?

It is very fast made, it is saterdaynight here you know

Cor

\\\
Private dtVBreg As DataTable

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateTables()
Dim dv As New DataView(dtVBreg)
DataGrid1.DataSource = dv
Dim cm As CurrencyManager
cm = CType(BindingContext(dv), CurrencyManager)
dv.Sort = "Name,Country"
Dim findObject(1) As Object
findObject(0) = "Terry Burns"
findObject(1) = "EU"
cm.Position = dv.Find(findObject)
DataGrid1.Select(cm.Position)
End Sub
Private Sub CreateTables()
Dim drel As DataRelation
dtVBreg = New DataTable("Persons")
dtVBreg.Columns.Add("Name")
dtVBreg.Columns.Add("Country")
For i As Integer = 0 To 7
dtVBreg.Rows.Add(dtVBreg.NewRow)
Next
dtVBreg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", "EU"}
dtVBreg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", "US"}
dtVBreg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", "US"}
dtVBreg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", "US"}
dtVBreg.Rows(4).ItemArray = New Object() _
{"Terry Burns", "EU"}
dtVBreg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", "US"}
dtVBreg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", "EU"}
End Sub
///
"John Hernry" <jo********@sasktel.com>
....
Cor,
So, If I understand you correctly, you are saying to create a second
dataview of the table, do my filter on it, find the record I need (which
will likely have to still be done by looping through the filtered records,
but at least far less of them), get the unique ID from the found record
then find that ID on the displayed dataview and move to that record. Is
that about right?

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a second
dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer
fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
.
Cor,
Thanks for the response. I have seen your responses to these type of
questions before and I was hoping you would respond.

Unfortunately, though, the filter isn't really what I'm after. I really
would like to keep all of the data visible so that the user can scroll
around in curiosity if need be. If you have ever used the find in
Access I am trying to build something along that line. Where I can
specify criteria such as: search in one field, all fields, at the
beginning of the field, end of the field, must match the entire field,
or case sensitive etc. I suspect that I am going to have to iterate
through each field of each row based on the search criteria. I was
hoping for a quicker method as this method will be slow. My database
currently has 30,000 records with 5 fields: ID, Source, Song, Artist,
Album.

I have tried the filter method, and it would work as a last resort, but
ultimately it isn't what I'm after. Any other suggestions?

John
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4*************@TK2MSFTNGP11.phx.gbl...
John,

I know that the dataview.find exist hower I did never use that one,
(probably because for that one the datarowcollection.find does(is) the
same and is easier to handle.

I think that you want more rows back and than the datarowfilter is
easier to handle.

The datarowfilter you set by (Keep in mind that the rowfilter is
dynamicly and reacts direct on the change of a filterfield) All is
typed by hand in this message so watch typos

\\\
dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
'SometingElse'"
//
(Mostly you have to make dynamicly a concatenated string, Think than to
enclose those in single quotes for string fields
\\\
For Each dvv As DataRowView In dv
dvv(0) = "Myfield"
Next
///
Or if you want that
\\\
For i as integer = 0 to dv.count-1
dv(i)(0) = "Myfield"
Next
///
I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
>I have been watching the dotnet newsgroups for a couple of weeks now
>and scouring the net looking for a solution to my datagrid find
>functionality. With no luck. I am hoping that you can help me.
>
> I am an old VB6 coder used to using Sheridan controls, and I am just
> starting to learn the .net world.
>
> I am upgrading my music catalogue database, where the data is stored
> in an Access mdb file.
>
> The datagrid is bound to a dataview and I can get the find to work in
> that it returns a valid row, but it is not the first row with that
> value.
>
> Here is my search code
> Dim dvData As DataView
>
> Dim cmBkMrk As CurrencyManager
>
> Dim intRec As Integer
>
> dvData = Me.dgrCatalogue.DataSource
>
> dvData.Sort = "Artist"
>
> cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)
>
> intRec = dvData.Find("Triumph")
>
> cmBkMrk.Position = intRec
>
> It is finding the band Triumph, and moving to the found row, but it is
> not the first row with the value Triumph. Why?
>
> While I am here, I have three more questions:
>
> 1) How do I perform a FindNext?
>
> 2) How do I perform wildcard searches?
>
> 3) How do I perform searches on more than one column? I have figured
> out how to sort on two columns, but what is the dvData.Find code?
>
>
>
> Thanks In Advance!
>
> Greg
>
>



Nov 21 '05 #6

P: n/a
Cor,
I have done this type of find, which initiated this posting. There are two
inherent problems. One - No wildcard searches. Two - Because my search
value is not unique, it does not necessarily return the first value (bug?).
This find will only find exact matches and I really am looking for wildcard
type searches without having to use a filter.

The find must also be able to perform a find next. So I would be able to
begin my search from a specified row.

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Os**************@TK2MSFTNGP14.phx.gbl...
John,

Seeing it again now I think that you are after this as the sample bellow?

It is very fast made, it is saterdaynight here you know

Cor

\\\
Private dtVBreg As DataTable

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateTables()
Dim dv As New DataView(dtVBreg)
DataGrid1.DataSource = dv
Dim cm As CurrencyManager
cm = CType(BindingContext(dv), CurrencyManager)
dv.Sort = "Name,Country"
Dim findObject(1) As Object
findObject(0) = "Terry Burns"
findObject(1) = "EU"
cm.Position = dv.Find(findObject)
DataGrid1.Select(cm.Position)
End Sub
Private Sub CreateTables()
Dim drel As DataRelation
dtVBreg = New DataTable("Persons")
dtVBreg.Columns.Add("Name")
dtVBreg.Columns.Add("Country")
For i As Integer = 0 To 7
dtVBreg.Rows.Add(dtVBreg.NewRow)
Next
dtVBreg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", "EU"}
dtVBreg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", "US"}
dtVBreg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", "US"}
dtVBreg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", "US"}
dtVBreg.Rows(4).ItemArray = New Object() _
{"Terry Burns", "EU"}
dtVBreg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", "US"}
dtVBreg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", "EU"}
End Sub
///
"John Hernry" <jo********@sasktel.com>
...
Cor,
So, If I understand you correctly, you are saying to create a second
dataview of the table, do my filter on it, find the record I need (which
will likely have to still be done by looping through the filtered
records, but at least far less of them), get the unique ID from the found
record then find that ID on the displayed dataview and move to that
record. Is that about right?

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a
second dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer
fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
.
Cor,
Thanks for the response. I have seen your responses to these type of
questions before and I was hoping you would respond.

Unfortunately, though, the filter isn't really what I'm after. I
really would like to keep all of the data visible so that the user can
scroll around in curiosity if need be. If you have ever used the find
in Access I am trying to build something along that line. Where I can
specify criteria such as: search in one field, all fields, at the
beginning of the field, end of the field, must match the entire field,
or case sensitive etc. I suspect that I am going to have to iterate
through each field of each row based on the search criteria. I was
hoping for a quicker method as this method will be slow. My database
currently has 30,000 records with 5 fields: ID, Source, Song, Artist,
Album.

I have tried the filter method, and it would work as a last resort, but
ultimately it isn't what I'm after. Any other suggestions?

John
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4*************@TK2MSFTNGP11.phx.gbl...
> John,
>
> I know that the dataview.find exist hower I did never use that one,
> (probably because for that one the datarowcollection.find does(is) the
> same and is easier to handle.
>
> I think that you want more rows back and than the datarowfilter is
> easier to handle.
>
> The datarowfilter you set by (Keep in mind that the rowfilter is
> dynamicly and reacts direct on the change of a filterfield) All is
> typed by hand in this message so watch typos
>
> \\\
> dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
> 'SometingElse'"
> //
> (Mostly you have to make dynamicly a concatenated string, Think than
> to enclose those in single quotes for string fields
> \\\
> For Each dvv As DataRowView In dv
> dvv(0) = "Myfield"
> Next
> ///
> Or if you want that
> \\\
> For i as integer = 0 to dv.count-1
> dv(i)(0) = "Myfield"
> Next
> ///
> I hope this helps?
>
> Cor
>
> "John Hernry" <jo********@sasktel.com>
>>I have been watching the dotnet newsgroups for a couple of weeks now
>>and scouring the net looking for a solution to my datagrid find
>>functionality. With no luck. I am hoping that you can help me.
>>
>> I am an old VB6 coder used to using Sheridan controls, and I am just
>> starting to learn the .net world.
>>
>> I am upgrading my music catalogue database, where the data is stored
>> in an Access mdb file.
>>
>> The datagrid is bound to a dataview and I can get the find to work in
>> that it returns a valid row, but it is not the first row with that
>> value.
>>
>> Here is my search code
>> Dim dvData As DataView
>>
>> Dim cmBkMrk As CurrencyManager
>>
>> Dim intRec As Integer
>>
>> dvData = Me.dgrCatalogue.DataSource
>>
>> dvData.Sort = "Artist"
>>
>> cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)
>>
>> intRec = dvData.Find("Triumph")
>>
>> cmBkMrk.Position = intRec
>>
>> It is finding the band Triumph, and moving to the found row, but it
>> is not the first row with the value Triumph. Why?
>>
>> While I am here, I have three more questions:
>>
>> 1) How do I perform a FindNext?
>>
>> 2) How do I perform wildcard searches?
>>
>> 3) How do I perform searches on more than one column? I have figured
>> out how to sort on two columns, but what is the dvData.Find code?
>>
>>
>>
>> Thanks In Advance!
>>
>> Greg
>>
>>
>
>



Nov 21 '05 #7

P: n/a
John, go to : http://www.planetsourcecode.com/

And search for a program called: DataEasy. It is a VB.NET program(with
source code) that will open any Access Database and allow searching
different columns(user selected) and what I like is that as you type into
the textbox it starts the search and picks all records in that field that
match what you are typing.
And it is pretty fast too.
Maybe, that will give you a couple of ideas.
james

"John Hernry" <jo********@sasktel.com> wrote in message
news:e8**************@TK2MSFTNGP09.phx.gbl...
Cor,
I have done this type of find, which initiated this posting. There are
two inherent problems. One - No wildcard searches. Two - Because my
search value is not unique, it does not necessarily return the first value
(bug?). This find will only find exact matches and I really am looking for
wildcard type searches without having to use a filter.

The find must also be able to perform a find next. So I would be able to
begin my search from a specified row.

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Os**************@TK2MSFTNGP14.phx.gbl...
John,

Seeing it again now I think that you are after this as the sample bellow?

It is very fast made, it is saterdaynight here you know

Cor

\\\
Private dtVBreg As DataTable

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateTables()
Dim dv As New DataView(dtVBreg)
DataGrid1.DataSource = dv
Dim cm As CurrencyManager
cm = CType(BindingContext(dv), CurrencyManager)
dv.Sort = "Name,Country"
Dim findObject(1) As Object
findObject(0) = "Terry Burns"
findObject(1) = "EU"
cm.Position = dv.Find(findObject)
DataGrid1.Select(cm.Position)
End Sub
Private Sub CreateTables()
Dim drel As DataRelation
dtVBreg = New DataTable("Persons")
dtVBreg.Columns.Add("Name")
dtVBreg.Columns.Add("Country")
For i As Integer = 0 To 7
dtVBreg.Rows.Add(dtVBreg.NewRow)
Next
dtVBreg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", "EU"}
dtVBreg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", "US"}
dtVBreg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", "US"}
dtVBreg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", "US"}
dtVBreg.Rows(4).ItemArray = New Object() _
{"Terry Burns", "EU"}
dtVBreg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", "US"}
dtVBreg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", "EU"}
End Sub
///
"John Hernry" <jo********@sasktel.com>
...
Cor,
So, If I understand you correctly, you are saying to create a second
dataview of the table, do my filter on it, find the record I need (which
will likely have to still be done by looping through the filtered
records, but at least far less of them), get the unique ID from the
found record then find that ID on the displayed dataview and move to
that record. Is that about right?

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a
second dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer
fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
.
> Cor,
> Thanks for the response. I have seen your responses to these type of
> questions before and I was hoping you would respond.
>
> Unfortunately, though, the filter isn't really what I'm after. I
> really would like to keep all of the data visible so that the user can
> scroll around in curiosity if need be. If you have ever used the find
> in Access I am trying to build something along that line. Where I can
> specify criteria such as: search in one field, all fields, at the
> beginning of the field, end of the field, must match the entire field,
> or case sensitive etc. I suspect that I am going to have to iterate
> through each field of each row based on the search criteria. I was
> hoping for a quicker method as this method will be slow. My database
> currently has 30,000 records with 5 fields: ID, Source, Song, Artist,
> Album.
>
> I have tried the filter method, and it would work as a last resort,
> but ultimately it isn't what I'm after. Any other suggestions?
>
> John
>
>
> "Cor Ligthert" <no************@planet.nl> wrote in message
> news:e4*************@TK2MSFTNGP11.phx.gbl...
>> John,
>>
>> I know that the dataview.find exist hower I did never use that one,
>> (probably because for that one the datarowcollection.find does(is)
>> the same and is easier to handle.
>>
>> I think that you want more rows back and than the datarowfilter is
>> easier to handle.
>>
>> The datarowfilter you set by (Keep in mind that the rowfilter is
>> dynamicly and reacts direct on the change of a filterfield) All is
>> typed by hand in this message so watch typos
>>
>> \\\
>> dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
>> 'SometingElse'"
>> //
>> (Mostly you have to make dynamicly a concatenated string, Think than
>> to enclose those in single quotes for string fields
>> \\\
>> For Each dvv As DataRowView In dv
>> dvv(0) = "Myfield"
>> Next
>> ///
>> Or if you want that
>> \\\
>> For i as integer = 0 to dv.count-1
>> dv(i)(0) = "Myfield"
>> Next
>> ///
>> I hope this helps?
>>
>> Cor
>>
>> "John Hernry" <jo********@sasktel.com>
>>>I have been watching the dotnet newsgroups for a couple of weeks now
>>>and scouring the net looking for a solution to my datagrid find
>>>functionality. With no luck. I am hoping that you can help me.
>>>
>>> I am an old VB6 coder used to using Sheridan controls, and I am just
>>> starting to learn the .net world.
>>>
>>> I am upgrading my music catalogue database, where the data is stored
>>> in an Access mdb file.
>>>
>>> The datagrid is bound to a dataview and I can get the find to work
>>> in that it returns a valid row, but it is not the first row with
>>> that value.
>>>
>>> Here is my search code
>>> Dim dvData As DataView
>>>
>>> Dim cmBkMrk As CurrencyManager
>>>
>>> Dim intRec As Integer
>>>
>>> dvData = Me.dgrCatalogue.DataSource
>>>
>>> dvData.Sort = "Artist"
>>>
>>> cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)
>>>
>>> intRec = dvData.Find("Triumph")
>>>
>>> cmBkMrk.Position = intRec
>>>
>>> It is finding the band Triumph, and moving to the found row, but it
>>> is not the first row with the value Triumph. Why?
>>>
>>> While I am here, I have three more questions:
>>>
>>> 1) How do I perform a FindNext?
>>>
>>> 2) How do I perform wildcard searches?
>>>
>>> 3) How do I perform searches on more than one column? I have
>>> figured out how to sort on two columns, but what is the dvData.Find
>>> code?
>>>
>>>
>>>
>>> Thanks In Advance!
>>>
>>> Greg
>>>
>>>
>>
>>
>
>



Nov 21 '05 #8

P: n/a
John,

All thougether is that what I am expecting while I sand my last message
however a newsgroup is difficult for that to communicate and this kind of
things have in my opinion to be done step by step.

My solution would be to do a search using the datarowfilter in an extra
dataview.
Than when the result is more than one, I would let the user choose from
those in an extra datagrid. When it is one, you have it direct and with zero
there should be a message.

Than you can use the solution I gave you as last one before this with the
dataview.find with only the ID to get the exact row in the main dataview,
datagrid.

I think that this will be a good solution.
(When you do not want the selection form on your screen you can make a
showdialog form for that, remember that you have only give the dv's by value
than everything is done, because that is a reference to the used dv's)

I hope this gives some ideas?

Cor

"John Hernry" <jo********@sasktel.com>
Cor,
I have done this type of find, which initiated this posting. There are
two inherent problems. One - No wildcard searches. Two - Because my
search value is not unique, it does not necessarily return the first value
(bug?). This find will only find exact matches and I really am looking for
wildcard type searches without having to use a filter.

The find must also be able to perform a find next. So I would be able to
begin my search from a specified row.

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Os**************@TK2MSFTNGP14.phx.gbl...
John,

Seeing it again now I think that you are after this as the sample bellow?

It is very fast made, it is saterdaynight here you know

Cor

\\\
Private dtVBreg As DataTable

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateTables()
Dim dv As New DataView(dtVBreg)
DataGrid1.DataSource = dv
Dim cm As CurrencyManager
cm = CType(BindingContext(dv), CurrencyManager)
dv.Sort = "Name,Country"
Dim findObject(1) As Object
findObject(0) = "Terry Burns"
findObject(1) = "EU"
cm.Position = dv.Find(findObject)
DataGrid1.Select(cm.Position)
End Sub
Private Sub CreateTables()
Dim drel As DataRelation
dtVBreg = New DataTable("Persons")
dtVBreg.Columns.Add("Name")
dtVBreg.Columns.Add("Country")
For i As Integer = 0 To 7
dtVBreg.Rows.Add(dtVBreg.NewRow)
Next
dtVBreg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", "EU"}
dtVBreg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", "US"}
dtVBreg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", "US"}
dtVBreg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", "US"}
dtVBreg.Rows(4).ItemArray = New Object() _
{"Terry Burns", "EU"}
dtVBreg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", "US"}
dtVBreg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", "EU"}
End Sub
///
"John Hernry" <jo********@sasktel.com>
...
Cor,
So, If I understand you correctly, you are saying to create a second
dataview of the table, do my filter on it, find the record I need (which
will likely have to still be done by looping through the filtered
records, but at least far less of them), get the unique ID from the
found record then find that ID on the displayed dataview and move to
that record. Is that about right?

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a
second dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer
fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
.
> Cor,
> Thanks for the response. I have seen your responses to these type of
> questions before and I was hoping you would respond.
>
> Unfortunately, though, the filter isn't really what I'm after. I
> really would like to keep all of the data visible so that the user can
> scroll around in curiosity if need be. If you have ever used the find
> in Access I am trying to build something along that line. Where I can
> specify criteria such as: search in one field, all fields, at the
> beginning of the field, end of the field, must match the entire field,
> or case sensitive etc. I suspect that I am going to have to iterate
> through each field of each row based on the search criteria. I was
> hoping for a quicker method as this method will be slow. My database
> currently has 30,000 records with 5 fields: ID, Source, Song, Artist,
> Album.
>
> I have tried the filter method, and it would work as a last resort,
> but ultimately it isn't what I'm after. Any other suggestions?
>
> John
>
>
> "Cor Ligthert" <no************@planet.nl> wrote in message
> news:e4*************@TK2MSFTNGP11.phx.gbl...
>> John,
>>
>> I know that the dataview.find exist hower I did never use that one,
>> (probably because for that one the datarowcollection.find does(is)
>> the same and is easier to handle.
>>
>> I think that you want more rows back and than the datarowfilter is
>> easier to handle.
>>
>> The datarowfilter you set by (Keep in mind that the rowfilter is
>> dynamicly and reacts direct on the change of a filterfield) All is
>> typed by hand in this message so watch typos
>>
>> \\\
>> dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
>> 'SometingElse'"
>> //
>> (Mostly you have to make dynamicly a concatenated string, Think than
>> to enclose those in single quotes for string fields
>> \\\
>> For Each dvv As DataRowView In dv
>> dvv(0) = "Myfield"
>> Next
>> ///
>> Or if you want that
>> \\\
>> For i as integer = 0 to dv.count-1
>> dv(i)(0) = "Myfield"
>> Next
>> ///
>> I hope this helps?
>>
>> Cor
>>
>> "John Hernry" <jo********@sasktel.com>
>>>I have been watching the dotnet newsgroups for a couple of weeks now
>>>and scouring the net looking for a solution to my datagrid find
>>>functionality. With no luck. I am hoping that you can help me.
>>>
>>> I am an old VB6 coder used to using Sheridan controls, and I am just
>>> starting to learn the .net world.
>>>
>>> I am upgrading my music catalogue database, where the data is stored
>>> in an Access mdb file.
>>>
>>> The datagrid is bound to a dataview and I can get the find to work
>>> in that it returns a valid row, but it is not the first row with
>>> that value.
>>>
>>> Here is my search code
>>> Dim dvData As DataView
>>>
>>> Dim cmBkMrk As CurrencyManager
>>>
>>> Dim intRec As Integer
>>>
>>> dvData = Me.dgrCatalogue.DataSource
>>>
>>> dvData.Sort = "Artist"
>>>
>>> cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)
>>>
>>> intRec = dvData.Find("Triumph")
>>>
>>> cmBkMrk.Position = intRec
>>>
>>> It is finding the band Triumph, and moving to the found row, but it
>>> is not the first row with the value Triumph. Why?
>>>
>>> While I am here, I have three more questions:
>>>
>>> 1) How do I perform a FindNext?
>>>
>>> 2) How do I perform wildcard searches?
>>>
>>> 3) How do I perform searches on more than one column? I have
>>> figured out how to sort on two columns, but what is the dvData.Find
>>> code?
>>>
>>>
>>>
>>> Thanks In Advance!
>>>
>>> Greg
>>>
>>>
>>
>>
>
>



Nov 21 '05 #9

P: n/a
Cor and James,
Thank you for your responses. I have taken all of your suggestions and will
be putting them into action on my project.

John

"John Hernry" <jo********@sasktel.com> wrote in message
news:e6**************@TK2MSFTNGP09.phx.gbl...
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find functionality.
With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in an
Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in that
it returns a valid row, but it is not the first row with that value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is not
the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured out
how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg

Nov 21 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.