Dbgrideh usage tips

Source: Internet
Author: User
Custom grid title
Complex title
Tdbgrideh allows you to create titles on multiple columns, for example:

Set dbgrideh. when the usemultititle attribute is true and the label or title of the field is filled, you can use the following rule: The text part or column title in the field label must be composed of several parts, and separated by "|", each common part of several columns is set to the same. Other fields or titles must contain the same text in the corresponding section.

For example:

Field1.displaylabel: = 'title1 | subtitle1 ';
Field2.displaylabel: = 'title1 | subtitle2 ';
Or
Dbgrideh. Columns [0]. Title. Caption: = 'title1 | subtitle1 ';
Dbgrideh. Columns [1]. Title. Caption: = 'title1 | subtitle2 ';
Pressed title
If column. Title. titlebutton is set to true, the title unit can be forced to be In the pressing mode. Write the ontitlebtnclick event to control the operation when the user clicks the title unit.

Display bitmap in title
To show bitmap in titles instead of caption use titleimages property of tdbgrideh and imageindex property of tcolumntitleeh.

Automatically sort titles with location IDs.
Tdbgrideh allows to show special sortmarking bitmaps (small triangles) in the right part of title cell. in order to automatically marking title by sortmarking bitmaps add dghautosortmarking to optionseh property. add dghmultisortmarking too in order to allow sortmarking several columns simultaneously. set column. title. titlebutton to true for titles which will have possibility to change sortmarkers at run time. at runtime clicking on title will change sortmarking. holding ctrl key allows to Mark several columns simultaneously. after user change sormarking grid call onsortmarkingchanged event. you can write this event to change sorting and reopen in dataset. use sortmarkedcolumns property to access to sortmarked columns.

Default title Attribute Value
Use tdbgrideh. columndefvalues. Title to set the default value of the title attribute.

Custom grid footer
Footer and statistical value
Tdbgrideh allows to show special row (footer) or rows at bottom part. use footerrowcount property to specify the number of footer rows in the grid. use footer or footers property of tcolumneh object to specify information which need to show in footer cells. footers property useful then you have more then one footer rows. footers is a collection of tcolumnfootereh objects where information from I-th aliment of collection will be show in I-Th cell of footer column. in footer cell, it is possible to show: sum value for specified field, record count, value of a specified field or static text. use property footer. valuetype or footers [I]. valuetype to specify which type of value will be show in footer cell. if valuetype = fvtstatictext, then set the property value to specify text which need to show. if valuetype = fvtfieldvalue, then you need to set property fieldname to specify field, value of which need to show. to force grid to calculate total values need to activate sumlist (dbgrideh. sumlist. active: = true ). set valuetype to fvtsum and grid must to show sum value of the column field in the footer cell, you can also specify column. footer. fieldname to calculate total value of the other field. set valuetype to fvtcount to force grid to show count of records in the footer cell.

Custom Grid Data Unit
the field value is displayed as a graph in the data unit.
tdbgrideh allows to show bitmaps from timagelist component depending on field values. to show bitmaps depending on field values need: Fill list of field values to column. keylist property (every value in separate line) and set column. imagelist property to imagelist control that has the bitmap in according index. set column. notinkeylistindex to index of Bitmap that will be shown if field's value does not correspond to any value in keylist (for instance you can set index of image for null field value ). at run time you are not allowed to edit bitmap in Column cell. use blank key and mouse click to set next value from column. keylist to the field; shift-blank key and shift-mouse click to set previous value from column. keylist. set column. dblclicknextval to true have allows to change value on mouse double click.

Check box logic and non-logical values
Grid automatically shows checkboxes for Boolean field. to show checkboxes for non Boolean fields fill first line of column. keylist property that corresponds to the checked state of the checkbox, second line-Non checked state, and set column. checkboxes ptoperty to true. line of keylist can represent more than one value in a semicolon-delimited list of items.

Data Row Height
Use the rowheight and rowlines attributes to specify the Row Height. The complete data Row Height = the row line height + the Row Height. Set rowsizingallowed to true to allow you to use the mouse to change the Row Height during running.

Setting column. wordwrap to true can display data rows in multiple Chinese lines. If the line is higher than the text line, it will wrap the line.

Show remarks field
Set drawmemotext to true to display text-style remarks ..

Customize cell fonts and colors
The font and color attributes in tdbgrideh describe the font and color of cells drawn in the data grid.
The font and color attributes in tcolumneh describe the font and color of cells drawn in the specified column.

Event customization cell font and color
There are several events that allow you to customize cell fonts and colors before creating cells. You can write the ondrawcolumncellevent event handle of tdbgrideh to draw data in the control grid unit. You can use the canvas attribute to draw cells. However, if you only want to change the font or color attributes, we recommend that you use the following events. You can write the ongetcellparams event of tdbgrideh to control the operations specified before the data unit is drawn. You can change the font and background color. This event is applicable when you want to change the font or color of the entire line. To change the attributes of cells in a specified column, you can use tcolumneh. ongetcellparams. Write this event to control the operations when a data unit is repainted or edited. Before a data unit is repainted, you can change the font, background color, alignment, image index, text, or check box. Before editing a column of data units, you can change the editing font, background color, text, or read-only status.

Default Value of column attribute

Use the columndefvalues attribute to set the default value of the column attribute. The newly created column obtains the attribute value from the columndefvalues attribute until it is specified for the first time.

Place the editor in the appropriate position of the grid.
Several fields are displayed in the drop-down list.
Several drop-down fields are displayed in the drop-down list. You need to set the lookupdisplayfields attribute of the column to the semicolons attribute of the field to separate multiple field names. The attribute named column. Field. lookupresultfield must be in the lookupdisplayfields list. The multi-field drop-down list can only be applied to drop-down fields.

Show drop-down columns

You can use the keylist and picklist attributes to display other texts in related fields. Keylist displays the values contained in the field instead of the values included in the picklist index. Column. notinkeylistindex to index of text from picklist that will be shown if field value do not contain keylist (for instance you can set index of text for null field value ). set column. dblclicknextval to true to change value on mouse double click.

Drop-down Calculator
For tdatefield and tdatetimefield fields, the inplace editor displays the drop-down button to display the drop-down calculator. Set column. buttonstyle to cbsnone to disable the drop-down button.

Set the editor color and font
The inplace editor can set the color and font of a data unit. The data unit uses the ongetcellparams event to control the color and font of the column. The inplace Editor automatically sets the Row Height to multi-row mode and sets the attribute wordwrap of the column to true.

Automatically fill in the grid column width to the grid customer area
Set autofitcolwidths to true to automatically reset the column width to set the grid width to the width of the customer zone. The minautofitwidth attribute determines the minimum width of the grid. The column width is recalculated.
3D or flat appearance
Use the optionseh attribute to display/hide fixed 3D frames, cold areas, footers, and data rows.

Use the flat attribute to display the data grid in a flat mode.

Import/export data from multiple formats to tdbgrideh.
The function set of ehlib can export data from dbgrideh to text, CSV, HTML, RTF, XLS and its internal format. It can save data to a stream (tstream object) or file.

Example
Pascal: savedbgridehtoexportfile (tdbgridehexportastext, dbgrideh1, 'c: \ temp \ file1.txt ', false );
C ++: savedbgridehtoexportfile (_ classid (tdbgridehexportastext), dbgrideh1, "C: \ temp \ file1.txt", false );

Ehlib function sets can be imported from text and data in its internal format to dbgrideh data sets. It can read data from a file or read data to a stream (tstream object ).

Other features
With the lookup editor, you can clear (set to null) The lookupkeyfield value at runtime. For example, select the entire text and press the delete key.

Cold Zone
The cold zone is the area that cannot be rolled on the left of the Data mesh set. Unlike Fixed columns, columns in the cold zone can obtain the editing focus. You can set the column set to the right by setting the frozencols attribute.

Incremental search

Tdbgrideh allows you to perform a specific "incremental" search in the grid column. When a user enters the incremental search, the user can display characters and grids, and search for text in the current column. Use the values of dghincsearch and dghpreferincsearch (in the optionseh option) to perform incremental search in the data grid. The dghincsearch value allows incremental search in the Data mesh. During running, you can use the following key for incremental search:

CTRL + F-start incremental search.
CTRL + enter-find the next matching record.
CTRL + Shift + enter-search for the previous matching record.

If dghincsearch in the optionseh option is read-only, the network automatically sets the incremental mode and returns the normal mode after the first key and 1.5 seconds. The value of dghpreferincsearch determines that the automatic incremental search mode of grid settings replaces unit editing when the first button is clicked.

Horizontal or vertical scroll bar
Use the vertsctollbar and horzsctollbar attributes to display/hide and track horizontal or vertical scroll bars.

Multiple choice
Tdbgrideh allows you to select records, columns, and rectangular areas in the selected area:

The following attributes are affected when multiple selections are allowed:

The dgmultiselect attribute in options-sets whether multiple options are allowed.

Dghclearselection property in options-sets whether to clear selected records when the user moves to the next unit.

Editactions attribute in options-set the operations that the user can perform on the selected records (for example, copy, cut, delete, paste, select all ).

Allowedselections attribute in options-set the type of the selected record (for example, row, column, and rectangular area ).

Selection attribute in options-set a current multiple-choice status, selected records, columns or rectangular areas, and access their attributes and functions.

Saves or restores the layers of grids and columns from the registry or INI file.
Tdbgrideh has a general setting to save and restore the network and column layers from the registry or INI file:

Restorecolumnslayout-restore the column order, width, and sorting flag from the registry.

Restorecolumnslayoutini-restore the column order, width, and sorting flag from the INI file.

Restoregridlayout-restore the column order, width, visibility, sorting flag, Sorting index, or row height from the registry.

Restoregridlayoutini-restore the column order, width, visible, sorting flag, Sorting index, or row height from the INI file.

Savecolumnslayout-Save the column order, width, and sorting flag to the Registry.

Savecolumnslayoutini-Saves the column order, width, and sorting flag to the INI file.

Savegridlayout-stores the column order, width, visualization, sorting flag, Sorting index or Row Height to the Registry.

Savegridlayoutini-Saves the order, width, and visibility of the column, sorting flag, Sorting index, or Row Height to the INI file.

The current version of tdbgrideh does not support the following features:
Tdbgrideh of this version does not support the following features:

Tdbgrideh cannot set the height of a single row in each data window.

Tdbgrideh cannot work like Treeview. It cannot have nodes and branches.

Tdbgrideh cannot merge data units horizontally or vertically.

Convert an existing TDBGrid component to a tdbgrideh component:

Although tdbgrideh is not inherited from the tcustomdbgrid component, tdbgrideh and TDBGrid still have some similar attributes.

It allows you to convert an existing TDBGrid component to tdbgrideh at only a small cost.

Follow the prompts below to convert an existing TDBGrid component to tdbgrideh:

Open an application that contains the TDBGrid component in Delphi ideProgram.

Sets the view mode as text (Alt-F12 ).

If key = vk_return then // key: Enter
Begin
If (grddetaildata. selectedindex = grddetaildata. Columns. Count-1) and not (dgrowselect in grddetaildata. Options) then
Begin
If (dgediting in grddetaildata. Options) and (grddetaildata. Row = grddetaildata. RowCount-1) Then // The table grid can be edited and the current cursor focus is on the last row
Acadddetailexecute (Self)
Else
Begin
Grddetaildata. Row: = grddetaildata. Row + 1; // change the cursor focus row to the next row (this statement does not need to be run when it is newly added
Grddetaildata. selectedindex: = 0 // change the cursor focus column to the first column
End;
End else
Begin
Grddetaildata. selectedindex: = grddetaildata. selectedindex + 1;
While grddetaildata. Columns [grddetaildata. selectedindex]. readonly do
Grddetaildata. selectedindex: = grddetaildata. selectedindex + 1;
End;
Key: = 0;
End;
If key = vk_insert then // Insert key: Add a record
Begin
Acadddetailexecute (Self );
Key: = 0;
End;
If key = vk_delete then // delte: delete a record
Begin
Acdeletedetailexecute (Self );
Key: = 0;
End;

1. Set the footerrowcount value of the dbgrideh attribute to 1;
2. Set the Active Value of the sumlist of the dbgrideh attribute to true;
3. Set the valuetype type of the footer column you want to match to fvtsum.
4. Run OK!
write when dataset is Enabled:
dbgrideh1.columns [0]. footer. Value: = inttostr (dbgrideh1.datasource. dataset. recordcount);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.