The Oracle Client .NET Data Provider

ADO.NET Navigation Control

Chapter 13 showed you the steps required to build a fairly standard Microsoft Windows based data access application. You might have noticed that creating buttons to allow the user to navigate through the contents of your DataSet is actually more time-consuming than creating DataAdapter objects and strongly typed DataSet objects or creating bound controls. However, the code and the buttons required to add those navigation features to your code are very basic.

To address this basic scenario, I created the ADO.NET Navigation Control. This control includes buttons that let you navigate through the contents of your DataSet. You can also use the control to add and delete rows in your DataSet, as well as submit the pending changes to your database. Figure B-8 shows a simple form that employs the ADO.NET Navigation Control.

Figure B-8

Using the ADO.NET Navigation Control on a Windows Form

Using the ADO.NET Navigation Control in a Windows-based application is simple. Once you've added the control to the Visual Studio .NET Toolbox, you need only to add an instance of the control to your form and set a few properties in order to use it in your application.

Adding the ADO.NET Navigation Control to the Visual Studio .NET Toolbox

If you're working with a Visual Studio .NET solution and you add the ADO.NET Navigation Control project to your solution, the control will be automatically available on the Windows Forms tab of the Visual Studio .NET Toolbox.

You can also add the Navigation Control to the Toolbox by right-clicking on a tab and choosing Customize Toolbox from the shortcut menu. In the dialog box that appears, select the .NET Framework Components tab, click the Browse button, and then select the Navigation Control's library. Click OK, and the control will be available in the Toolbox.

Setting the Data Properties of the ADO.NET Navigation Control

When you add the Navigation Control to a Windows Form, you'll see that it exposes four basic data properties: DataSource, DataMember, DataAdapter, and DataTable.

You set the DataSource and DataMember properties of the Navigation Control just as you would for a DataGrid object. The Navigation Control works much like bound controls such as the TextBox and DataGrid controls. The Navigation Control uses the values you specify for the DataSource and DataMember properties to reference the appropriate CurrencyManager for the Windows Form. It uses this CurrencyManager object internally to navigate through the underlying data structure.

The Navigation Control also includes Fill and Update buttons. To make these features work, you must set the DataAdapter and DataTable properties of the Navigation Control.

Setting the Remaining Properties of the ADO.NET Navigation Control

Three other properties are available for the Navigation Control: FillOnLoad, ConfirmDeletes, and ShowTips.

The Navigation Control has a FillOnLoad property that's set to True by default. This setting controls whether the Navigation Control will implicitly call the DataAdapter object's Fill method when the form starts up.

The Navigation Control exposes a ConfirmDeletes property, which is set to True by default. When you click the Navigation Control's Delete button, if the ConfirmDeletes property is set to True, the control will prompt the user to confirm the deletion.

By default, the Navigation Control displays a ToolTip when you move the mouse over one of the control's buttons. You can turn this behavior off by setting the Navigation Control's ShowTips property to False.



Microsoft ADO. NET Core Reference
Microsoft ADO.NET (Core Reference) (PRO-Developer)
ISBN: 0735614237
EAN: 2147483647
Year: 2002
Pages: 104
Authors: David Sceppa

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net