Home > Back-end >  Online teaching, can't try many times, ask where is the key!!!!!!!!!!
Online teaching, can't try many times, ask where is the key!!!!!!!!!!

Time:10-10

Second, to find the field in the DBGrid
So-called lookup fields (LookUpField), that is, the value of a key field in the DBGrid the corresponding fields from another database, using the search field technology, not only can effectively avoid typos, more flexible and DBGrid display mode, can not display the key fields, and display the source database corresponding to another field data,
For example, we show in the DBGrid and editing staff information, including employee Numbers, the worker's name, domicile of origin, place unit number, and unit number from another database table, the library, called "unit number" key fields, if we directly display and edit the unit number, will be in front of the Numbers 1, 2, 3 and so on is not intuitive, error-prone when editing, but if a display and edit is a repository of the corresponding unit name, will be very straightforward, that is supported by the DBGrid lookup fields, the benefits of
Realize DBGrid lookup fields also don't need any statements, specific design steps are as follows:
1, in the form placed on Table1 and Table2, DataSource1, DBGrid1, DBNavigator1 controls such as object, according to the following table set each object's properties:
Object attribute value
Table1 DataBase sy1
TableName ZGK. DBF//worker information
Table2 DataBase sy1
TablenAME DWK. DBF//unit database
DataSource1 DataSet Table1
DbGrid1 DataSource DataSource1
DBNavigator1 DataSource Datasource1
2. Double-click the Table1
In the pop-up Form1. Table1 window, use right-click pop-up menu, click AddFields menu item; Select all fields, click the OK button,
3, modify step 2 new fields of DisplayLabel properties, Table1ZGBH fields, for example, in ObjectInspector window choose Table1ZGBH
Modify properties DisplayLabel=employee Numbers, the rest of the field,
4, set Table1DWBH. Visible=False,
5, in Form1. Table1 window, right-click pop-up menu, click the NewField menu item, a new search field DWMC, set the corresponding properties in the pop-up window
Press the OK button to confirm; In setting Table1DWMC ObjectInspector window. DisplayLabel=unit name,
6, in Form1. Write into the Oncreate event statement:
Table1. The Open;
7, press F9 to run, when the cursor is moved to a record unit name field, use the mouse to click on the field, namely a drop-down list, click the down arrow to the right, but in the drop-down list to choose, here you can see, the contents of the drop-down list from the unit information database, and other contents can't input,
  • Related