|
Free
C# Tutorials
|
![]() |
home |
Stay
at Home and Learn
|
|||||
Move Backwards through the Database |
||||||
|
<< Part of an ongoing lesson - first part is here >> We can use similar code to move backwards through the records in the
database. Double click your new button to get at the coding window. Now add the following:
The If statement is now only checking the inc variable. We need to check if it's greater than zero. If it is, we can deduct 1 from inc, and then call our NavigateRecords methods. When the form loads, remember, inc will be 0. So if we tried to move back one record after the form first loads the programme would crash. It would crash because we'd be trying to access Rows[-1]. Run your programme and test it out. Click you Previous Record button and you should see this:
Click both of your buttons and make sure you can move back and forward through the records. You programme shouldn't crash! Next, we'll see how to jump to the end, and to the start of the database.
<-- Navigation Buttons | Move to the First and Last Record --> <--Back to the C# .NET Contents Page View all our Home Study Computer Courses
|