Find Next Record (1 Viewer)

Matty

...the Myth Buster
Local time
Today, 10:17
Joined
Jun 29, 2001
Messages
396
While I’m asking questions, I may as well see if anyone can help me with a problem that I still haven’t solved…

In a class library, I’ve created a Find form that works like the search you’d find in Access (form pops up, you choose the field you want to search and it finds the next record). I’ve created my base Find form in my class and I have the logic pretty much figured out to find the first record. The problem is that I don’t know how to scroll to the found record on the main form properly.

My Find form has a combobox, cboFindBy (field to search) and a textbox to enter the criteria, txtFind. When the popup loads (as modal), it is passed a form parameter (frmMainForm) which is the form the Find was launched from as well as a DataView parameter (dvFindData) that contains the records to search through (in this case, the records behind frmMainForm). The popup then loops through the controls on the passed main form, finding the fields that I’ve flagged as “searchable” and adds them to the cboFindBy combobox.

When the Search button is hit on my popup form, I search though the passed DataView using the criteria entered on the form. I grab the primary key from the first record that I find, and that’s where I don’t know where to go.

If I just wanted to find the first record, I could just save this PK into a public variable and do a bsBindingSource.Find with it on the main form (I think). But what I want to happen is to do a sort of “Find Next” functionality where they can keep clicking Search and it’ll go to the next found record and so on.

So basically I need to trigger a search on the main form whenever my Search button gets clicked, but I need to keep this generic enough so that this form is re-usable. I’d like to use the passed frmMainForm variable, but how?
 

Kodo

"The Shoe"
Local time
Today, 11:17
Joined
Jan 20, 2004
Messages
707
look up making custom events
 

Matty

...the Myth Buster
Local time
Today, 10:17
Joined
Jun 29, 2001
Messages
396
Thanks -- that may be what I'm needing. I guess what I'm going to have to do is make a base form class and inherit it from System.Windows.Form and add my custom events to it. Then rather than passing a standard form to the Find popup, I'd be passing my extended form and that would allow me to call the custom event.

Does that sound about right?
 

Kodo

"The Shoe"
Local time
Today, 11:17
Joined
Jan 20, 2004
Messages
707
You don't need to inherit Form in a new class.. you can add your events to the base form.
 

Users who are viewing this thread

Top Bottom