Editing databases and spreadsheets in VB

zhaozj2021-02-11  187

There are many powerful controls in VB50, where data controls are collaborate with some binding controls (such as text boxes, picture boxes, and ActiveX controls), which can easily implement various database records, forms and even spreadsheets. Browse and edit operations.

The following describes the instance, where the data control is used to record browsing, mobile, editing, etc., while the DBGRID binding control is mainly used to display a complete database and spreadsheet. The specific steps are as follows:

1 Visual control:

(1) Create a new form in a new project.

(2) Select the "Part" item from the "Project" menu, open the Parts dialog, select "Micorosoft Data Bound Grid Control" (eg DBGRID control), which will appear in the toolbox.

(3) Double-click the DBGRID icon, which will appear in the middle of the form, drag and drop it with the mouse to the appropriate size.

(4) Double-click the data control icon, and wait after the icon appears on the form, drag and drop it to the appropriate size.

2 Set the properties for each control:

(1) Data Control (DATA1)

Attribute value

Connect Access (Excel) This is a default. If you are selected, you can set it to FoxPro (or Excel), etc.

DatabaseName / nwindmdb selection Browse database (or spreadsheet) name (/ xxxxsl) must set the full (including path) file name

RecordSource Author Select the data table name or field name in the database

(2) Data Grid Binding Control (DBGRID)

Attribute value

DataSource Data1 data comes from data controls

AllowAddnew True can directly add a record directly for TRUE

AllowUpdata True can modify the record directly for True

3 Operation:

(1) Use the F5 key, or click the triangular flag in the toolbar, which starts running, the full table (or selected spreadsheet) of the selected database data table after running will appear on the screen.

(2) Click on the different triangular markers in the data control to move the record and cursor for browsing.

(3) In the cursor, you can modify the recording content, and VB50 will automatically save the changes.

转载请注明原文地址:https://www.9cbs.com/read-4810.html

New Post(0)