InfoPower4000 wwGrid控件的一些应用技巧
------摘至InfoPower4000的帮助文档
叶正盛
2003-12-6
复选框可以设置为单击或双击(缺省)操作
property EditControlOptions: TwwEditControlOptions;
Description
This property defines specific settings for controls embedded in an InfoPower grid
Value Meaning
ecoCheckboxSingleClick When true, the end-user need only single-click a checkbox cell in the grid to toggle it. When false, a dbl-click is required.
ecoSearchOwnerForm When true, the grid searches for embedded controls on the grid抯 owner form. When false, the grid will search the grid parent form. Usually you will want to set this property to true.
ecoDisableCustomControls If True, then the grid will not use the assigned custom controls during editing.
ecoDisableDateTimePicker If False, then the grid will disable the automatic creation and use of the TwwDBDateTimePicker control to edit dates or time fields.
ecoDisableEditorIfReadOnly If True, then the grid will disable the inplace editor if the field is not editable.
TwwDBGrid.ExportOptions
property ExportOptions: TwwExportOptions;
Description
This property defines specific settings for exporting data from the grid to a series of different file types or to the clipboard for other applications to use. Choose from HTML, formatted text, tabbed delimited text, comma delimited text (this is a common spreadsheet format known as .CSV), or the Excel SYLK (.SLK) format. By setting ExportOptions | Options | esoClipboard to True, the data will be saved to the clipboard in the chosen ExportOptions | ExportType format. If dgMultiSelect is enabled in the grid and an enduser has selected some records, then you have the choice of exporting only the selected records or the current contents of the filtered or nonfiltered dataset. Just set the options and call the Save method of the ExportOptions object.
保存GRID到HTML文件
Saving to HTML File
The following example demonstrates how you would save the grids data to an HTML File.
1. Set the Grid's Filename property to xxxxx.html. Where xxxxx is the name of the HTML file you wish to generate.
2. Set the ExportOptions | ExportType to wwgetHTML
3. Call the Save method(ExportOptions.save) and the generated file will be created. If you wish to save this to the clipboard so that you can paste the resulting HTML into Microsoft Word or Excel 2000, then set the ExportOptions | Options | esoClipboard to True.
4. If you want to programmatically display this with the default browser. Add shellapi to your form uses clause and call it like:
ShellExecute(Handle, 'OPEN', PChar(wwDBGrid1.ExportOptions.Filename), nil, nil, sw_shownormal);
导出GRID到EXCEL
Saving selected data to Excel using the clipboard
The following example demonstrates how you would save data to Excel using the clipboard.
1. Set the ExportOptions | ExportType to wwgetSYLK You could optionally also set it to wwgetTxt for exporting just the data, or wwgetHTML (for special formatting, coloring, and for Excel 2000).
2. Set the ExportOptions | Options | esoClipboard to True. If you wish to export to a file set this to False and set the filename to the format xxxxx.slk.
3. Call the save method.(ExportOptions.save)
4. Open Excel and then select Edit | Paste or Edit | Paste Special.
可以导出的格式说明
TwwGridExportType
TwwGridExportType = (wwgetTxt, wwgetHTML, wwgetSYLK, wwgetXML);
This type determines the actual format that the data is stored in. The properties for this object are as follows:
Property Description
wwgetTxt When ExportType is set to wwgetTxt, records will be saved to the specified FileName in a Text Format, or if esoClipboard is in the ExportOptions | Options property then the record data will be saved to the clipboard in the CF_Text clipboard format. The delimiter settings will determine the actual format of the exported text. See the Delimiter property for more details.
wwgetHTML This format is one of the most flexible and powerful export formats. Depending on the ExportOptions | Options settings, it is possible to preserve the colors, fonts, group headings, column widths, footers, and controls that are in the grid. Save to an HTML file and use an internet browser to view the resulting table, or save to the clipboard and paste to Microsoft Word or Excel.
wwgetSYLK Microsoft Excel supports the spreadsheet format .SLK, which can retain the current column widths and group headings, fonts that are set at the time of export. Setting ExportOptions | ExportType to wwgetSYLK will cause data to be saved in that format.
wwgetXML Not Implemented Yet. Provided for future XML exporting.
设置当前记录的颜色
TwwGridPaintOptions
This class defines how a grid or datainspector control is painted. You can load a background bitmap and have different sections of the grid be blended with certain colors.
Properties
The properties for this object are as follows:
Property Description
ActiveRecordColor Set this property to define the color that the inspector or grid use to paint the background of the data cells for the active record. This defaults to clNone, which means that the color of the control is used to paint the background.
AlternatingRowColor This defines the color that the inspector or grid use to paint the background for every other row. This property defaults to clNone, which means that the row colors are not alternated. See also the property AlternatingRowRegions to configure which section will paint with the alternating color.
AlternatingRowRegions Set this property to enable/disable the alternating color support within the grid or inspector.
arrFixedColumns Enable alternating colors in the fixed columns
arrDataColumns Enable alternating colors in the data cells
arrActiveDataColumn Enable alternating colors for the active record column. This property only applies when using a data inspector. It is ignored when using a grid.
BackgroundBitmap Assign this property to enable a background tile for the inspector or grid. You should make your tiles small so that your executables do not become large. We do not recommend non-tiled backgrounds as this may slow the performance of your grid抯 painting.
Note: When using non-tiled backgrounds, you may want to set FastRecordScrolling to false. For more information see the property FastRecordScrolling.
Data Type: TPicture
BackgroundDrawStyle Set this property to change the way the background bitmap is drawn.
bdsTile Paint the background bitmap as a tile
bdsStretch Stretches the background bitmap into the control抯 client area.
bdsTopLeft Paints the background bitmap starting at the top left of the control.
bdsCenter Paints the background bitmap centered within the grid or inspector.
BackgroundOptions Use this property to control how and where the background bitmap is painted. You may wish to enable the blending flags as they allow your grid or inspector to provide stunning and professional visual effects.
Note: the background blending is automatically disabled when running on systems with less than 256 colors.
coFillDataCells When true, the data area is filled with the background bitmap. Set this to false to prevent the background from being used in the data area.
coBlendFixedRow When true, the fixed row is painted with a blended bitmap. The background bitmap is blended with the TitleColor (TwwDBGrid), or IndicatorRow.Color (TwwDataInspector).
coBlendFixedColumn When true, the fixed column is painted with a blended bitmap. The background bitmap is blended with the TitleColor (TwwDBGrid), or CaptionColor (TwwDataInspector).
coBlendActiveRecord When true, the active record is painted with a blended bitmap. The background bitmap is blended with the color defined by PaintOptions.ActiveRecordColor. This property is not currently supported for the TwwDBGrid.
coBlendAlternatingRow When true, the alternating row color (PaintOptions.AlternatingRowColor) is blended with the background bitmap before it is painted into the grid or inspector.
FastRecordScrolling Set this to true to force the grid or inspector to repaint its whole contents after any scroll operations take place. This will reduce the performance of your control抯 painting during scrolling operations, but will ensure that your grid or inspector抯 background do not shift position after the scrolling takes place.
Note: For many tiled backgrounds, FastRecordScrolling can be left as False as the effect of tile being shifted does not harm the visual effect of the tile. If you are not using a tile, but instead have set BackgroundDrawStyle to something besides bdsTile, then you will likely want to set FastRecordSrolling to False.