How to: Add Navigation Buttons (Devices)
Use these procedures to provide navigation buttons for viewing different rows in the data source. This technique works around the lack of .NET Compact Framework support for the DataNavigator class of the .NET Framework.
The following steps, written in C# and relying on the Customers table of the Northwind database, assume that you have a dataset or resultset in the Data Sources window. For more information, see How to: Add a Database to a Device Project. In a real project, you would include bounds checking, which is not shown in the code samples here.
Note
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.
To set up for adding navigation buttons
Drag and drop a table from the Data Sources window onto a Windows Form.
Drag and drop a button onto the form.
Set the Text property of the button appropriately (for example, "Next").
Double-click the button on the form to open the code editor at the button click event handler.
Use the following code examples to code First, Next, Previous, and Last button event handlers.
To code a First button
- Type this.customersBindingSource.MoveFirst();
To code a Next button
- Type this.customersBindingSource.MoveNext();
To code a Previous button
- Type this.customersBindingSource.MovePrevious();
To code a Last button
- Type this.customersBindingSource.MoveLast();
See Also
Tasks
How to: Generate SqlCeResultSet Code (Devices)