With Delphi or VB programming, in the database to operate the records, often used a name called the Data Navigator component, through this component, can be very convenient for the implementation of the data table has been bound to this component to browse the records. Is there such a component in Visual C #? The answer is no. However, because Visual C # has powerful database processing capabilities, it is easier to do a program similar to this component. This article is to introduce the process of the specific production of this program.
First, the main functions of the program introduction:
The program opens the Book data table in the local acess database (Sample.mdb) and then puts the
The field is bound to the text box provided by the program, and is displayed. Through the program's four buttons "first record", "Tail record", "previous", "next", to achieve the book data table browsing. The running interface of the program is as follows:
Second, the program design and operation of the environment settings:
(1) Windows 2000 Server Edition
(2) Microsoft acess Data Component 2.6 (MADC 2.6)
Third, the programming difficulty and should pay attention to the question:
(1) How to implement the data table in a text box to display the field:
If you assign the value of a field directly to a text box, when you use the Next button to browse the data record, the value of the text box will not change. How to make a text box dynamically display the value of a field based on the record pointer in the datasheet is one of the key and difficult points of this article.
This article implements the dynamic display of field values by binding the value of the field in the datasheet to the Text property of the TextBox. Implement this process to use the DataBindings property of the text box and the Add method in it? creak Kuimo bending their heads ㄈ? The name of the text component. Databindings.add ("Text", DataSet object, data table and field name);
In the program specific as follows:
T_bookid. Databindings.add ("Text", myDataSet, "Books.bookid");
This allows you to implement the field values to display based on the record pointer.