Program TForm 1. Button 1Click (sender: toobject);
var MyStringList:TStringList;
begin
MyStringList := TStringList。 Create;
attempt
Conversation. GetTableNames('lklb ','',False,False,MyStringList);
List box 1. items:= MyStringList;
finally
My list of strings. Free;
End;
End;
The syntax of the GetTableNames method is as follows.
Syntax: session.gettablenames (databasename, pattern, extensions, systemtables, list).
Parameter description:
Databasename- database name.
Pattern- data table type, which is used to limit which type of data table is returned, such as. DB or. DBF。 If it is empty, all types of data tables are returned, and wildcards can be used.
Extensions-Boolean variable that controls whether the returned data table has an extension.
System tables-For some databases, there are system tables. If set to True, the returned table names include system tables. Usually set to False.
List- a string list that holds the name of the data table.
2 DBNavigator component. The DBNavigator component is mainly used to provide simple control buttons for users to manipulate records in datasets. Users can move the record pointer, insert, delete, modify, save and refresh the record by clicking the button. Its VisibleButtons property can specify which buttons are displayed. By setting the Hints property, you can set other dynamic prompt information for each control button. The dynamic prompt information set by the user will overwrite the original prompt information, so we'd better write the prompt information in Chinese.
3 DBtext component. It is equivalent to the Label component, but it is only used to display the field values in the database, and its display content changes with the change of the record pointer. Its DataField property specifies the field name of the content to be displayed.
4 DBEdit component. Used to display and modify data table field values. Because DBEdit is generally used to modify or add new records, its ReadOnly property is generally set to False. If it is set to True, the field content cannot be modified.
5 DBMemo component. It is mainly used to display and edit the values of large binary (BLOB) fields in database tables. It is usually used to process the value of a memo field and can display multiple lines of text. The MaxLength property sets the value of this property to limit the number of characters that users can enter into the DBMemo component. If this value is set to 0, it means that there is no limit to the number of characters entered. Note: During the operation, users cannot cut, copy and paste the text information displayed in the DBMemo component. Because the DBMemo component contains a lot of text information, it takes a lot of time to update and display the information when the pointer moves. Users can control whether the memo field in the table is automatically displayed through the AutoDisplay property. When AutoDisplay is set to False, only the field names in the corresponding table are displayed in the DBMemo component, but the text information in the field is not displayed. If the user wants to browse the text information in the field, he can double-click the inside of the DBMemo component with the left mouse button. When the AutoDisplay property is set to True, the field values in the corresponding database tables will be automatically displayed in the DBMemo component.
6 DBImage component. Similar to the DBMemo component, it is used to display and edit bitmap image fields of BLOB type in database tables. If the ReadOnly property value of DBImage is set to False, users are allowed to edit bitmap images, such as cutting or copying images to the clipboard, or pasting them from the clipboard into the DBImage component.
7 DBListBox component. Used to display a list of field values for users to choose when modifying field values. During the operation, users can assign values to the fields corresponding to the DBListBox component by clicking the optional items, and users can't enter field values that don't exist in the list box from the keyboard.
8 DBComboBox component. It can be considered as a combination of DBEdit component and DBListBox component, and the options of DBComboBox are also designed by programmers at the design stage. When modifying a field in the current record, the user can directly enter a new field, or open the drop-down list box to select one of the options (limited by the style attribute). The Sorted property determines whether the options in the list box are sorted alphabetically. Tip: The DBComboBox component and the ComboBox component have similar intelligent search functions: when the user enters a character or Chinese character in the edit box, open the drop-down box, and the drop-down box will automatically move to the same option as the first character, and then go down in turn. Usually, users only need to enter a few characters to find the corresponding options. This is very useful when there are many choices. Of course, the Sorted property must be set to True, otherwise the required options may not be found.
9 DBLookupListBox component. This component provides multiple options, but these options are read from other related database tables, rather than manually entered at design time, which is its characteristic. The ListSource property represents the data source of the list option of the DBLookupListBox component, which is very important, otherwise the DBLookupListBox component will not know where to get the data to fill the list box. Typically, the DataSource component is placed and connected to it. The ListField property specifies the data field to fill in the list box. You can list the contents of more than one field at a time, but you can only select the contents of one field to assign a value to the field specified by the DBLookupListBox component, so you must specify KeyField Keyfield. The KeyField property and the ListField property are used together to indicate which field content in the selection list is assigned to the field specified by the DBLookupListBox component (specified by the DataField property). If there is only one field in the list, then KeyField and ListField should be the same. KeyField attribute must be specified. This property allows multiple fields to be set at a time, and each field can be separated by a semicolon. The advantage of using multiple list fields is that users can learn other information when selecting the contents of key fields.
10 DBLookupComboBox component. This component combines the functions of DBEdit component and DBLookupListBox component. Users can directly enter field values in this component or select an option from the drop-down list box, but the options in the drop-down list box are read from other related database tables. Its property settings can refer to the previous DBComboBox and DBLookupListBox components.
Note: the above four components DBListBox, DBLookupListBox, DBComboBox and DBLookupComboBox can only be used for table components, but not for query components.
1 1 DBCheckBox component. Usually used to connect Boolean fields in a data table. In this way, users do not need to input true/false, which is more convenient to use. The difference between it and the CheckBox component is that the DBCheckBox component must connect boolean fields in the data table, and the CheckBox value is given in the program.
12 DBRadioGroup component. Connect to a field whose value can only be one of the fixed values of the DBRadioGroup component (selected by the user), and the user can only select one option. Double-click its Items property to open the option name editor, where you can enter the title of the option. & # 1 18alues attribute double-click to open the data editor corresponding to the option. The data entered here corresponds to the previous item. When the user selects the first option, the first data will be selected from the 1 18 list of values and the corresponding fields will be filled in. Note: If the attribute 1 18 values is not given, the title of the item will be passed to the corresponding field as data.
13 DBRichEdit component. It is the same as the DBEdit component, except that the field it connects to must be in RichText format. The DBRichEdit component does not provide the formatting function of RichText text. If you want to modify the text format, the application must do it by itself. When the text format changes but not the text itself, the application must explicitly set the Edit property of the data source control to True, otherwise the changed result cannot be saved.
14 dbcrlgrid component. Is a very interesting component, which allows multiple panel windows to be opened at the same time to display and modify records, and these records are not the same, but several continuous records (user settings), and users can modify multiple records at the same time. The ColCount property specifies how many columns there are and the RowCount property specifies how many rows there are. The Orientation property has two values to choose from: the GoHorizontal scroll bar is displayed horizontally and the GoVertical scroll bar is displayed vertically. Usage: after placing the DBCtrlGrid component, place a data browsing component such as DBEdit in its "active" panel (i.e. the upper left panel with smooth surface and no stripes in the figure). Components can only be placed on the active panel, but not on other panels. After running, each panel will have the same interface as the active panel. Then set the number of rows and columns of the panel through ColCount and RowCount, and set the position of the scroll bar with the Orientation attribute. Note: When the scroll bar moves or when the focus moves between panels, the data will be saved automatically. Clicking the arrows at both ends of the scroll bar moves a different number of records than clicking the mouse in the space between the slider and the arrow. The former moves a column or a row, and the latter moves the number of records on the screen.
15 DBChart component. It is almost exactly the same as the Chart component, except for one more function, which is to get data from the data table to make graphics. Usage: After placing the data set and data source components in the interface, place the DBChart component, and double-click to open the setting interface. Different from the chart component, under the series option, there is an item named dataset in the data source option drop-down list. After it is selected, the data table option will appear below, and then you can select the corresponding number field in Labels, X, Y for drawing.
One of the tips: implement the method of class DBComboBox list in DBGrid.
Function to be realized: When entering a field in the DBGrid grid, clicking the field will bring up a drop-down list (similar to DBComboBox), from which the user can select the required field content. There are several fixed options in the list box, such as male and female.
For example, if there is a "gender" field in the data table, we will let this field have a drop-down list function. Needless to say, put a table, a DataSource and a DBGrid component on the form and match them together. Double-click DBGrid 1 and edit DBGrid 1. Columns window, click the Add all Fields button to add all fields of Table 1 to DBGrid 1. Editing DBGrid 1. Columns window, click to select a field, such as Gender. In the object inspector window, click the ellipsis after the picklist property, and enter two lines in the string list editor window, namely "male" and "female", to close the string list editor window. Set the Active property of Table 1 to True, then run the program and click the gender field of a record in DBGrid 1 with the mouse, and a drop-down list will appear. The options in the list are "Male" and "Female". You can select one of them or manually enter the field contents.
The second trick is to implement the method of DBLookUpComboBox list class in DBGrid.
The method in tip 1 is suitable for table entry in fields with fewer options. If there are thousands of commodity names, manual input is obviously not appropriate. At this time, we use the search field to realize it. The content of the drop-down list comes from the corresponding field values in another data table, such as the pre-made product name data table.