国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
DBGridEh使用技巧
DBGridEh使用技巧
 
首先將dbgrideh的一個(gè)頁(yè)腳數(shù)屬性FooterRowCount設(shè)置為 1;
再將dbgrideh的屬性中的sumlist中的Active 設(shè)置為 True;
第三步:打開(kāi)dbgrideh的字段列表;選擇需要求和的字段,有個(gè)屬性Footer下有
FieldName是求和的字段;
ValueType是操作的類型;(fvtSum 求和; fvtAvg 平均值; fvtCount 記錄數(shù);
fvtStaticText 靜態(tài)文本; fvtFieldValue 字段值 )

使用 TDBSumList 組件 還記得以前有朋友問(wèn)過(guò)這樣一個(gè)問(wèn)題:在 DBGrid 下如何像 Excel 一樣能夠做統(tǒng)計(jì)計(jì)算,實(shí)話說(shuō),使用 DBGrid 來(lái)做的話著實(shí)不易,不過(guò)現(xiàn)在有了這個(gè)咚咚,相信會(huì)簡(jiǎn)單些。以下是摘錄的一些使用上的說(shuō)明:

【TDBSumList說(shuō)明】
你可以使用TDBSumList在可視動(dòng)態(tài)變化數(shù)據(jù)集中進(jìn)行記錄統(tǒng)計(jì)。在你想查看的數(shù)據(jù)集中設(shè)置相關(guān)的數(shù)據(jù)字段,然后寫(xiě) SumListChanged 事件來(lái)指定在TDBSumList發(fā)生改變后所要做的操作。TDBSumList 的 SumCollection 屬性上一個(gè) TDBSum 對(duì)象容器。每個(gè) TDBSum 對(duì)象是一個(gè)可以指定集合值的元件。 FieldName 和 GroupOperation 決定了集合值的類型,SumValue 控制當(dāng)前的集合值。

TDBSumList 被埋藏于 DBGridEh 組件中,因此所的下面有關(guān)TDBGridEh.SumList 的說(shuō)明與TDBGirdEh的TDBGridEh.SumList 屬性的說(shuō)明是一樣的。

【如何工作以及為什幺有時(shí)SumList的集合值計(jì)算不正確?】
你知道 data-aware 控件與數(shù)據(jù)集是通過(guò) TDataLink 對(duì)象相連接的。 TDataLink 不允許快速重新計(jì)算集合值。例如,當(dāng)從數(shù)據(jù)集中刪除記錄時(shí),數(shù)據(jù)集發(fā)送deDataSetChange事件給所有的TDataLink對(duì)象,在當(dāng)前局部過(guò)濾發(fā)生改變時(shí),同樣的事件也被發(fā)送了。因此當(dāng) TDataLink 接收到該事件時(shí),它不得不在所有的數(shù)據(jù)集中重新計(jì)算集合值,甚至于僅從數(shù)據(jù)集中刪除一條記錄。在激活后, TDBSumList 重載了數(shù)據(jù)集的下列事件: OnAfterEdit, OnAfterInsert, OnAfterOpen, OnAfterPost, OnAfterScroll, OnBeforeDelete, OnAfterClose。這種方法避免了在所有的數(shù)據(jù)集中它。在不需要它時(shí),又會(huì)出現(xiàn)其它的問(wèn)題,比如: T 運(yùn)行時(shí)指定這些事件。在指定上述事件之一以前,關(guān)閉 SumList。
在下面的情形下,SumList 發(fā)出存取錯(cuò)誤信息。 SumList 試著向數(shù)據(jù)集返回事件,但數(shù)據(jù)集數(shù)據(jù)并未被刪除。在SumList(或網(wǎng)格)以及數(shù)據(jù)集放置在不同的窗體(數(shù)據(jù)模塊)這種情況下,可以顯示數(shù)據(jù)。在這種情況下,試著在從數(shù)據(jù)集或數(shù)據(jù)模塊中數(shù)據(jù)集數(shù)據(jù)被刪除時(shí)關(guān)閉SumList。
如果你使用SetRange或ApplyRange事件,SumList 將不能跟蹤數(shù)據(jù)集中發(fā)生的變化。但可以調(diào)用 SumList.RecalAll 方法。
在非BDE數(shù)據(jù)集的主/明細(xì)表中,SumList 不能跟蹤數(shù)據(jù)變化。在主數(shù)據(jù)集激活狀態(tài)數(shù)據(jù)集發(fā)生變化后,調(diào)用 SumList.RecalAll 方法。
在任何其它情況下,如果你發(fā)現(xiàn)了其它SumList的計(jì)算值不正確,你都可以調(diào)用 RecalAll 方法。


2003-12-5 15:24:54 如何使用 Ehlib 實(shí)現(xiàn)自動(dòng)排序 在 Ehlib 的 DataService 文件夾下提供了一些可以使數(shù)據(jù)集實(shí)現(xiàn)自動(dòng)排序的文件。TDBGridEh 使用這些文件中的相關(guān)對(duì)象可以實(shí)現(xiàn)當(dāng)排序標(biāo)記發(fā)生變化時(shí)實(shí)現(xiàn)自動(dòng)排序。

如果你改變了數(shù)據(jù)網(wǎng)格及標(biāo)題的排序標(biāo)記而沒(méi)有書(shū)寫(xiě) OnSortMarkingChanged 事件,數(shù)據(jù)網(wǎng)格將嘗試自動(dòng)進(jìn)行數(shù)據(jù)排序。DBGridEhDataService 嘗試通過(guò) GetDatasetFeaturesForDataSet 查找 TDataSet 中可以排序的特定的對(duì)象。正如你所知道的,TDataSet 不支持?jǐn)?shù)據(jù)排序,但它的派生對(duì)象 TQuery 或 TClientDataSet 卻允許實(shí)現(xiàn)數(shù)據(jù)排序。使用過(guò)程 RegisterDatasetFeaturesEh ,你可以注冊(cè) TDatasetFeaturesEhClass 類,該類可以實(shí)現(xiàn)對(duì) TQuery, TADOQuery 以及 TClientDataSet 對(duì)象進(jìn)行排序。簡(jiǎn)單地通過(guò) uses 子句添加 Ehlib...(EhlibBDE,EhlibADO,EhlibCDS)的單元之一到你的工程的任意單元中,與它們相連的數(shù)據(jù)網(wǎng)格將自動(dòng)對(duì)該數(shù)據(jù)集進(jìn)行排序。 EhLibBDE, EhLibADO, EhLibCDS 通過(guò)在單元數(shù)據(jù)集中調(diào)用 RegisterDatasetFeaturesEh 過(guò)程來(lái)實(shí)現(xiàn)初始化。對(duì)于其它數(shù)據(jù)集類型,你必須編寫(xiě)、并注冊(cè)可以實(shí)現(xiàn)該數(shù)據(jù)集排序的新對(duì)象。書(shū)寫(xiě)過(guò)程 T[你的數(shù)據(jù)集]DatasetFeaturesEh.ApplySorting ,你可以存取那些使用了 SortMarkedColumns 屬性的列以實(shí)現(xiàn)直接排序。你可以查看 DbUtilsEh 單元中的示例以明白如何編寫(xiě)T[你的數(shù)據(jù)集]DatasetFeaturesEh 類及查看 EhLibBDE 單元以明白如何注冊(cè) T[你的數(shù)據(jù)集]DatasetFeaturesEh 類。

引擎 數(shù)據(jù)集 單元文件

BDE TQuery EhLibBDE
ADO TADOQuery EhLibADO
ClientDataSet TClientDataSet EhLibCDS
DBExpress TSQLQuery EhLibDBX
InterBase Express TIBQuery EhLibIBX

【譯【者注】:
實(shí)際上,實(shí)現(xiàn)該功能非常簡(jiǎn)單(以下我以BDE為例說(shuō)明如何實(shí)現(xiàn)自動(dòng)排序):
1.在窗體上放置一個(gè) DBGridEh 組件,并將其連接到相應(yīng)的 BDE 數(shù)據(jù)集;
2.將該組件的[OptionsEn]中的 dgAutoSortMarking 屬性設(shè)置為 True;
3.雙擊該組件,在其彈出的屬性編輯器中添加相關(guān)字段;
4.將要排序的字段的屬性列表的 [Title]的 TitleButton 屬性設(shè)置為 True;
5.最后,千萬(wàn)不要忘了在 uses 子句中加上 EhlibBDE單元。

好了,使用上面的方法,你會(huì)發(fā)現(xiàn)原來(lái)通過(guò) Ehlib 實(shí)現(xiàn)數(shù)據(jù)的自動(dòng)排序居然如些簡(jiǎn)單!


2003-12-5 15:39:37 以下這段文字摘自《Delphi 園地》【定制網(wǎng)格標(biāo)題 】--
-【復(fù)雜標(biāo)題】
TDBGridEh 允許在多列上創(chuàng)建標(biāo)題,設(shè)置 DBGridEh.UseMultiTitle 屬性為 True 并且填充字段的標(biāo)簽或列標(biāo)題的標(biāo)題,可以使用下面的規(guī)則:字段標(biāo)簽中的文本部分或列標(biāo)題必須由幾部分組成,并且用 "|" 分割,幾個(gè)列的每一個(gè)通用部分都設(shè)置為相同。其它字段或標(biāo)題必須在相應(yīng)的部分包含同樣的文本。

例如:
Field1.DisplayLabel := 'Title1|SubTitle1';
Field2.DisplayLabel := 'Title1|SubTitle2';

DBGridEh.Columns[0].Title.Caption := 'Title1|SubTitle1';
DBGridEh.Columns[1].Title.Caption := 'Title1|SubTitle2';

-【按鈕式標(biāo)題】
設(shè)置Column.Title.TitleButton 為 True可以強(qiáng)制標(biāo)題單元為按鈕式。寫(xiě) OnTitleBtnClick事件來(lái)控制用戶單擊標(biāo)題單元時(shí)的操作。

-【在標(biāo)題中顯示位圖】
To show bitmap in titles instead of caption use TitleImages property of TDBGridEh and ImageIndex property of TColumnTitleEh.

-【自動(dòng)用位置標(biāo)識(shí)排序標(biāo)題】.
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.

-【標(biāo)題屬性的默認(rèn)值】
使用TDBGridEh.ColumnDefValues.Title來(lái)設(shè)置標(biāo)題屬性的默認(rèn)值。

【定制網(wǎng)格頁(yè)腳】--
-【頁(yè)腳以及統(tǒng)計(jì)值】
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.

-【定制網(wǎng)格數(shù)據(jù)單元】
在數(shù)據(jù)單元中顯示字段值為圖形。
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.

【檢查框式的邏輯及非邏輯值】
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.

【數(shù)據(jù)行高度】
使用 RowHeight 和 RowLines 屬性來(lái)指定數(shù)據(jù)行高。完整的數(shù)據(jù)行高 = 行線高度+行高。設(shè)置 RowSizingAllowed 為 True 以允許可以在運(yùn)行是使用鼠標(biāo)來(lái)改變行高。
設(shè)置Column.WordWrap為T(mén)rue可以使數(shù)據(jù)行中文本多行顯示。如果行高>文本行,它就換行。

【顯示備注字段】
設(shè)置 DrawMemoText to True來(lái)顯示文本式的備注字段。.

【定制單元格字體及顏色】
TDBGridEh 中的 Font 和 Color 屬性描述了數(shù)據(jù)網(wǎng)格中繪制單元格的字體和顏色。
TColumnEh 中的 Font 和 Color 屬性描述了指定列中繪制單元格的字體和顏色。

【事件定制單元格字體及顏色】
有幾個(gè)事件可以讓你能夠在繪制單元格前定制單元格字體和顏色。你可以寫(xiě)TDBGridEh的OnDrawColumnCellEvent事件句柄來(lái)在控制在網(wǎng)格單元中繪制數(shù)據(jù)。你可以使用Canvas屬性的方法來(lái)繪制單元格。但是如果你只想改變字體或顏色的屬性,我建議你使用下面的事件。你可以寫(xiě)TDBGridEh的OnGetCellParams事件來(lái)控制在繪制數(shù)據(jù)單元以前所指定的操作。你可以改變繪制字體及背景色。這個(gè)事件適合你在想改變整行的字體或顏色時(shí)使用。如果你想改變指定列中單元格的屬性,你可以使用TColumnEh.OnGetCellParams。寫(xiě)這個(gè)事件用來(lái)控制在一列數(shù)據(jù)單元被重繪或編輯時(shí)的操作。在一列數(shù)據(jù)單元被重繪以前,你可以改變繪制字體,背景色,對(duì)齊方式,圖像索引,文本或檢查框。在編輯一列數(shù)據(jù)單元以前,你可以改變編輯字體,背景色,文本或只讀狀態(tài)。

【列屬性的默認(rèn)值】
使用ColumnDefValues屬性來(lái)設(shè)置列屬性的默認(rèn)值。新創(chuàng)建的列將從ColumnDefValues屬性中獲得屬性值,并且直到第一次為其指定值為止。

【在網(wǎng)格的適當(dāng)位置放置編輯器】--
-【在下拉列表中顯示幾個(gè)字段】
在下拉列表中顯示幾個(gè)下拉字段,需要設(shè)置列的LookupDisplayFields屬性到字段的Semicolons屬性來(lái)分割多個(gè)字段名。命名為Column.Field.LookupResultField的屬性必須位于LookupDisplayFields列表中。多字段的下拉列表只能應(yīng)用于下拉字段。

-【顯示下拉方式的列】
你可以通過(guò)KeyList 和 PickList 屬性在相關(guān)的的字段中顯示其它文本。KeyList顯示包含在字段的值而非PickList索引所包含的值。 Column.NotInKeyListIndex to index of text from PickList that will be shown if field value do not contain in 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.

-【下拉式計(jì)算器】
對(duì)于 TDateField 和 TDateTimeField 字段,inplace 編輯器將顯示下拉按鈕以顯示顯示下拉計(jì)算器。設(shè)置 Column.ButtonStyle 為 cbsNone 以禁止顯示下拉按鈕。

【設(shè)置編輯器顏色和字體】
Inplace編輯器可以設(shè)置數(shù)據(jù)單元的顏色和字體。數(shù)據(jù)單元使用OnGetCellParams 事件來(lái)控制列的顏色和字體。 Inplace 編輯器在行高>一行的高度時(shí)自動(dòng)設(shè)置為多行模式并且將列的屬性 WordWrap 設(shè)置為T(mén)rue.

【自動(dòng)填充網(wǎng)格列寬到網(wǎng)格客戶區(qū)】
設(shè)置AutoFitColWidths為T(mén)rue以自動(dòng)重置列寬來(lái)設(shè)置網(wǎng)格的寬度等于客戶區(qū)寬度。 MinAutoFitWidth 屬性決定網(wǎng)格的最小寬度,列寬將會(huì)被重新計(jì)算。

【3D或平面外觀】
使用 OptionsEh 屬性來(lái)顯示/隱藏固定的3D框架,冷區(qū),頁(yè)腳以及數(shù)據(jù)行。
使用 Flat 屬性來(lái)設(shè)置用平面方式顯示數(shù)據(jù)網(wǎng)格。

【從多種格式導(dǎo)入/導(dǎo)出數(shù)據(jù)到TDBGridEh】
EhLib 的函數(shù)集可以從DBGridEh導(dǎo)出數(shù)據(jù)到Text, Csv, HTML, RTF, XLS以及其內(nèi)部格式。它可以保存數(shù)據(jù)到流(TStream對(duì)象)或文件。

例子
Pascal: SaveDBGridEhToExportFile(TDBGridEhExportAsText,DBGridEh1,'c:\temp\file1.txt',False);
C++: SaveDBGridEhToExportFile(__classid(TDBGridEhExportAsText),DBGridEh1,"c:\\temp\\file1.txt",false);

EhLib 的函數(shù)集可以從 Text以及其內(nèi)部格式的數(shù)據(jù)導(dǎo)入到DBGridEh的數(shù)據(jù)集中。它可以從文件中讀取數(shù)據(jù)或讀取數(shù)據(jù)到流(TStream對(duì)象)。

【其它特性】--
用lookup 編輯器,你可以在運(yùn)行時(shí)清空(設(shè)置為Null) LookupKeyField 值。比如選擇整個(gè)文本然后按Delete鍵。

-【冷區(qū)】
冷區(qū)是數(shù)據(jù)網(wǎng)格列集左邊顯示的不可滾動(dòng)的區(qū)域。與固定列不同的是,冷區(qū)的列可以獲得編輯焦點(diǎn)??梢酝ㄟ^(guò)設(shè)置FrozenCols屬性來(lái)設(shè)置右邊不可滾動(dòng)的列集。

-【增量搜索】
TDBGridEh 允許用戶在網(wǎng)格列中實(shí)現(xiàn)特定的“增量”搜索。當(dāng)用戶進(jìn)入增量搜索時(shí)他可以顯示字符以及網(wǎng)格,并且在當(dāng)前的列中查找文本。使用 dghIncSearch 和 dghPreferIncSearch的值(在OptionsEh 選項(xiàng)中) 在數(shù)據(jù)網(wǎng)格中操作增量搜索。 dghIncSearch 值允許在數(shù)據(jù)網(wǎng)格中進(jìn)行增量搜索。運(yùn)行時(shí)你能夠使用下面的鍵進(jìn)行增量搜索:

Ctrl+F - 開(kāi)始增量搜索。
Ctrl+Enter - 查找下一個(gè)匹配記錄。
Ctrl+Shift+Enter - 查找前一個(gè)匹配記錄。

如果OptionsEh選項(xiàng)中的 dghIncSearch 是只讀的,那幺網(wǎng)絡(luò)將自動(dòng)設(shè)置增量模式在第一次按鍵以及1.5秒后返回普通模式。 dghPreferIncSearch 值決定網(wǎng)格設(shè)置自動(dòng)增量搜索模式在第一次按鍵時(shí)替代單元編輯。

【水平或垂直滾動(dòng)條】
使用 VertSctollbar, HorzSctollbar 屬性來(lái)顯示/隱藏以及跟蹤水平或垂直滾動(dòng)條。

【多選】
TDBGridEh 允許在選定的區(qū)域上進(jìn)行選擇記錄,列以及矩形區(qū)域等操作:

×允許多選會(huì)影響下面這些屬性:
Options 選項(xiàng)中的 dgMultiSelect 屬性 - 設(shè)置是否允許多選。
Options 選項(xiàng)中的 dghClearSelection 屬性- 設(shè)置在用戶移到下一個(gè)單元時(shí)是否清除已選記錄。
Options 選項(xiàng)中的 EditActions 屬性 -設(shè)置用戶可以在已選記錄上執(zhí)行哪些操作(比如,拷貝,剪切,刪除,粘貼,全選等)。
Options 選項(xiàng)中的 AllowedSelections 屬性-設(shè)置允許選定記錄的類型(比如,行,列,矩形區(qū)域等)。
Options 選項(xiàng)中的 Selection 屬性-設(shè)置一個(gè)當(dāng)前的多選狀態(tài),已選記錄,列或矩形區(qū)域以及存取它們的屬性和函數(shù)。

【從注冊(cè)表或ini文件中保存或恢復(fù)網(wǎng)格和列的層次】
TDBGridEh 有一個(gè)常規(guī)設(shè)置來(lái)從注冊(cè)表或ini文件中保存和恢復(fù)網(wǎng)絡(luò)以及列的層次:
RestoreColumnsLayout - 從注冊(cè)表中恢復(fù)列的次序,寬度,排序標(biāo)志。
RestoreColumnsLayoutIni - 從ini文件中恢復(fù)列的次序,寬度,排序標(biāo)志。
RestoreGridLayout - 從注冊(cè)表中恢復(fù)列的次序,寬度,可視,排序標(biāo)志,排序索引或行高。
RestoreGridLayoutIni - 從ini文件中恢復(fù)列的次序,寬度,可視,排序標(biāo)志,排序索引或行高。
SaveColumnsLayout - 保存列的次序,寬度,排序標(biāo)志到注冊(cè)表中。
SaveColumnsLayoutIni - 保存列的次序,寬度,排序標(biāo)志到ini文件中。
SaveGridLayout - 保存列的次序,寬度,可視,排序標(biāo)志,排序索引或行高到注冊(cè)表中。
SaveGridLayoutIni - 保存列的次序,寬度,可視,排序標(biāo)志,排序索引或行高到ini文件中。

『以下內(nèi)容僅供參考了,因?yàn)椴恢浪莻€(gè)版本是多少,目前最新的版本是3.2吧,俺正在用,感覺(jué)很不錯(cuò)啊~~』
當(dāng)前版本的TDBGridEh不支持的特性:
TDBGridEh 不能設(shè)置每一個(gè)數(shù)據(jù)窗口中單獨(dú)行的行高。
TDBGridEh 不能象TreeView那樣工作。它不能擁有節(jié)點(diǎn)和枝葉。
TDBGridEh 不能橫向或縱向合并數(shù)據(jù)單元。

【將已存在的TDBGrid組件轉(zhuǎn)換為T(mén)DBGridEh組件】:
盡管TDBGridEh并不是從TCustomDBGrid組件繼承而來(lái)的,但是在TDBGridEh和TDBGrid中還是有一些相似的屬性。
它允許僅用一點(diǎn)點(diǎn)代價(jià)來(lái)轉(zhuǎn)換已存在的TDBGrid組件到TDBGridEh。

【注意】:可以按照下面的提示來(lái)轉(zhuǎn)轉(zhuǎn)換已存在的TDBGrid組件到TDBGridEh:
在Delphi的IDE中打開(kāi)包含有TDBGrid組件的應(yīng)用程序。
設(shè)置視圖方式為文本方式(Alt-F12)。
if key=VK_RETURN then //Key:回車
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 //從表GRID能進(jìn)行編輯和當(dāng)前光標(biāo)焦點(diǎn)在最后一行時(shí)
acAddDetailExecute(self)
else
begin
grdDetailData.Row:=grdDetailData.Row+1; //改變光標(biāo)焦點(diǎn)行到下一行(當(dāng)為新增加時(shí),這句不用運(yùn)行
grdDetailData.SelectedIndex:=0 //改變光標(biāo)焦點(diǎn)列到第一列
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鍵:新增一條記錄
begin
acAddDetailExecute(self);
key:=0;
end;
if key=VK_Delete then //Delte: 刪除一條記錄
begin
acDeleteDetailExecute(self);
key:=0;
end;

【頁(yè)腳合計(jì)】
1、設(shè)置DBGRIDEH屬性的FooterRowCount值為1;
2、設(shè)置DBGRIDEH屬性的SumList的Active值為true;
3、設(shè)置你要求和的該列的Footer的ValueType類型為fvtSum;
4、運(yùn)行OK!
在DataSet打開(kāi)時(shí)寫(xiě):
DBGridEh1.Columns[0].Footer.Value := IntToStr DBGridEh1.DataSource.DataSet.RecordCount);


2003-12-5 16:56:13 Ehlib 的 DBGridEh 控件怎樣才能像 dxDBGrid 控件那樣輸出文件到 EXCEL以下是EHLIB的導(dǎo)出代碼:(其實(shí)EHLIB的DEMO1中已有)

procedure TInvoiceManager.ppmSaveSelectionClick(Sender: TObject);
var ExpClass:TDBGridEhExportClass;
Ext:String;
begin
SaveDialog1.FileName := 'file1';
if (ActiveControl is TDBGridEh) then
if SaveDialog1.Execute then
begin
case SaveDialog1.FilterIndex of
1: begin ExpClass := TDBGridEhExportAsText; Ext := 'txt'; end;
2: begin ExpClass := TDBGridEhExportAsCSV; Ext := 'csv'; end;
3: begin ExpClass := TDBGridEhExportAsHTML; Ext := 'htm'; end;
4: begin ExpClass := TDBGridEhExportAsRTF; Ext := 'rtf'; end;
5: begin ExpClass := TDBGridEhExportAsXLS; Ext := 'xls'; end;
else
ExpClass := nil; Ext := '';
end;
if ExpClass <> nil then
begin
if UpperCase(Copy(SaveDialog1.FileName,Length(SaveDialog1.FileName)-2,3)) <>
UpperCase(Ext) then
SaveDialog1.FileName := SaveDialog1.FileName + '.' + Ext;
SaveDBGridEhToExportFile(ExpClass,TDBGridEh(ActiveControl),
SaveDialog1.FileName,False);
end;
end;
end;


2003-12-5 17:05:48 Ehlib 在 Delphi 7 中的安裝(我可是花了半天的力氣才搞定的哦)Delphi 7中的安裝方法

1. 把 EhLib 中的 common 和 DataService 文件拷貝到 Delphi7 目錄中.
2.在 TOOLS->Environment Options->Library->Library Path 中添入EHLIB路徑。
3.打開(kāi)新建文件夾中的 EHLIB70.DPK ,編譯一下,但不要安裝。
4.打開(kāi)Ehlib中的DclEhLib70.DPK,編譯,安裝
5. 在Delphi 7中打開(kāi)DclEhLib70.dpk,編譯并安裝。
6. 組件面板中出現(xiàn)一個(gè)EhLib的組件頁(yè)。
7. 打開(kāi)附帶的DEMOS,編譯并運(yùn)行,測(cè)試安裝成功。



2003-12-8 16:41:54 DBGridEh控件的頁(yè)腳屬性怎幺設(shè)?0、將dBGridEh.FooterRowCount := 1
1、將DBGridEh.SumList.Active := True;
2、將Columns[要求和的字段].Footer.ValueType := vtSum;
就行了

最后要注意,在FormCloseQuery事件中,一定要將SumList.Active := False,因?yàn)樵跀?shù)據(jù)集中的數(shù)據(jù)多了以后,F(xiàn)ormClose會(huì)讓DBGridEh釋放所有EhLib資源,會(huì)使得退出很慢,所以將SumList.Active := False不會(huì)引起退出很慢


2003-12-10 11:22:37 如何實(shí)現(xiàn)在DbgridEh中不同的行顯示不同的顏色?或某一些條件的行顯示特定的顏色?【實(shí)現(xiàn) DBGridEh 隔行分色顯示】
procedure TForm1.DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
begin
if DBGridEh1.SumList.RecNo mod 2 = 1 then
Background := $00FFC4C4
else
Background := $00FFDDDD;
end;


【DBGridEh 在某些條件下某行顯示特定顏色】
procedure TForm1.DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor; State: TGridDrawState);
begin

//在 name 字段值為 aaa 的行設(shè)置行背景色(ado 設(shè)置情況下)
if ADOQuery1.FieldByName('name').AsString = 'aaa' then
Background := $00FFC4C4

//在 xm 字段值為 Li ming 的行設(shè)置行背景色(bde 設(shè)置情況下)
else if DBGridEh1.DataSource.DataSet.FieldByName('xm').AsString = 'Li ming' then
Background := $00FFC4C4
else
Background := $00FFDDDD;

end;


2003-12-10 14:19:28 DBGridEh 控件導(dǎo)出文件到 EXCEL 的補(bǔ)充說(shuō)明(關(guān)于多表頭導(dǎo)出的設(shè)計(jì)思路) 如果表頭是著樣的:
|Mergetitle|
------------
Col1|Col2
分析表頭幾層,然后根據(jù)其表頭的'|' 將,其還原成
|Mergetitle|Mergetitle
----------------------
Col1 |Col2
再導(dǎo)入到Excel里合并單元格即可!


2003-12-10 14:55:16 在dbgrideh中允許選擇多行,如何知道哪些行被選中?是個(gè)BOOKMARK類型的屬性。
SelectedRows: TBookmarkList
procedure TForm1.Button1Click(Sender: TObject);
var
i, j: Integer;
s: string;
begin
if DBGrid1.SelectedRows.Count>0 then
with DBGrid1.DataSource.DataSet do
for i:=0 to DBGrid1.SelectedRows.Count-1 do
begin
GotoBookmark(pointer(DBGrid1.SelectedRows.Items[i]));
for j := 0 to FieldCount-1 do
begin
if (j>0) then s:=s+', ';
s:=s+Fields[j].AsString;
end;
Listbox1.Items.Add(s);
s:= '';
end;
end;


2003-12-10 15:06:19 dbgrideh 上選擇多行之后,要求把所選擇的記錄全部添加入SQL數(shù)據(jù)庫(kù)的一個(gè)固定表中。dbgrideh.selectedrows記載了所有被選擇行的bookmark;利用SelectedRows和GotoBookmark完成。代碼如下:

procedure TForm1.Button1Click(Sender: TObject);
var
i, j: Integer;
s: string;
begin
if DBGrid1.SelectedRows.Count>0 then
with DBGrid1.DataSource.DataSet do
for i:=0 to DBGrid1.SelectedRows.Count-1 do
begin
GotoBookmark(pointer(DBGrid1.SelectedRows.Items[i]));
for j := 0 to FieldCount-1 do
begin

if (j>0) then s:=s+', ';
s:=s+Fields[j].AsString;
end;
Listbox1.Items.Add(s);
s:= '';
end;
end;


2004-2-11 12:45:10 在dbgrideh中直接點(diǎn)擊title就可按點(diǎn)擊的那個(gè)字段排序的方法第一種方法(未測(cè)試)
procedure TForm1.DBGridEh1TitleClick(Column: TColumnEh);
begin
//點(diǎn)擊GridEh標(biāo)題排序
if (Column.Title.SortMarker = smNoneEh) or (Column.Title.SortMarker = smDownEh) then
begin
ADOQuery1.SORT := COLUMN.FIELDNAME;
Column.Title.SortMarker := smUpEh
end
else
begin
ADOQuery1.SORT := COLUMN.FIELDNAME + ' DESC';
Column.Title.SortMarker := smDownEh
end;
end;

第二種方法(未測(cè)試)
procedure TPrintMai_frm.DBGridEh1TitleClick(Column: TColumnEh);
var
sortstring: string;
begin //進(jìn)行排序
with Column do
begin
if FieldName = '' then
Exit;
case Title.SortMarker of
smNoneEh:
begin
Title.SortMarker := smDownEh;
sortstring := Column.FieldName + ' ASC';
end;
smDownEh: sortstring := Column.FieldName + ' ASC';
smUpEh: sortstring := Column.FieldName + ' DESC';
end; //數(shù)據(jù)集排序。
try
DM.DataModule1.qry2.Sort := sortstring //dataset為實(shí)際數(shù)據(jù)集變量名
except
end;
end;
end;


2004-3-24 17:34:05 ehlib的顏色控制及打印From:
http://www.delphibbs.com/keylife/iblog_show.asp?xid=191

很多說(shuō)根據(jù)條件在數(shù)據(jù)網(wǎng)格中顯示不同顏色的說(shuō)法都是在DrawColumnCell事件里,這樣顯示沒(méi)有問(wèn)題,但在ehlib中如果想打印出來(lái)可就不行了。
ehlib提供了GetCellParams事件,可以顯示和打印
//只能顯示,不能打印
procedure TfrmQueryContractInfo.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
var
OldColor,OldColumnColor:TColor;
v:TColCellParamsEh;
begin
{ OldColor:=DBGrid1.Canvas.Font.Color ;
if (Column.Field.FieldName = '填制調(diào)單時(shí)間') then
if (DBGrid1.DataSource.DataSet.FieldByName('填制調(diào)單時(shí)間').AsDateTime >DBGrid1.DataSource.DataSet.FieldByName('應(yīng)發(fā)貨時(shí)間').AsDateTime) then
begin
//v:=TColCellParamsEh.Create ;
//Column.GetColCellParams(true,v);
//v.Font.Color :=clRed;
//Column.FillColCellParams(v);
//v.Free;
DBGrid1.Canvas.font.Color := clRed;
end;

//Column.GetColCellParams .FillColCellParams()

if (Column.Field.FieldName = '移交時(shí)間') then
if (DBGrid1.DataSource.DataSet.FieldByName('移交時(shí)間').AsDateTime >DBGrid1.DataSource.DataSet.FieldByName('應(yīng)移交時(shí)間').AsDateTime) then
DBGrid1.Canvas.Font.Color := clRed;

if (Column.Field.FieldName = '填制運(yùn)輸單時(shí)間') then
if (DBGrid1.DataSource.DataSet.FieldByName('填制運(yùn)輸單時(shí)間').AsDateTime >DBGrid1.DataSource.DataSet.FieldByName('填制調(diào)單時(shí)間').AsDateTime) then
DBGrid1.Canvas.Font.Color := clRed;

DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
DBGrid1.Canvas.Font.Color:=OldColor;
}
end;
//可以顯示,可以打印
procedure TfrmQueryContractInfo.DBGrid1GetCellParams(Sender: TObject;
Column: TColumnEh; AFont: TFont; var Background: TColor;
State: TGridDrawState);
var
OldColor,OldColumnColor:TColor;
v:TColCellParamsEh;
begin
//OldColor:=DBGrid1.Canvas.Font.Color ;
if (Column.Field.FieldName = '填制調(diào)單時(shí)間') then
if (DBGrid1.DataSource.DataSet.FieldByName('填制調(diào)單時(shí)間').AsDateTime >DBGrid1.DataSource.DataSet.FieldByName('應(yīng)發(fā)貨時(shí)間').AsDateTime) then
AFont.Color := clRed;

if (Column.Field.FieldName = '移交時(shí)間') then
if (DBGrid1.DataSource.DataSet.FieldByName('移交時(shí)間').AsDateTime >DBGrid1.DataSource.DataSet.FieldByName('應(yīng)移交時(shí)間').AsDateTime) then
AFont.Color := clRed;

if (Column.Field.FieldName = '填制運(yùn)輸單時(shí)間') then
if (DBGrid1.DataSource.DataSet.FieldByName('填制運(yùn)輸單時(shí)間').AsDateTime >DBGrid1.DataSource.DataSet.FieldByName('填制調(diào)單時(shí)間').AsDateTime) then
AFont.Color := clRed;

if (Column.Field.FieldName = '實(shí)際到貨時(shí)間') then
if (DBGrid1.DataSource.DataSet.FieldByName('實(shí)際到貨時(shí)間').AsDateTime >DBGrid1.DataSource.DataSet.FieldByName('要求到貨時(shí)間').AsDateTime) then
AFont.Color := clRed;
//DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
//DBGrid1.Canvas.Font.Color:=OldColor;
end;


2004-3-29 20:12:46 DBGridEH 所有欄位自動(dòng)寬度的實(shí)現(xiàn)interface
THackDBGridEH = class(TCustomdbgrideh)
end;

procedure OptimizeGrid(AGrid: TCustomDbGridEh);

implementation
procedure OptimizeGrid(AGrid: TCustomDbGridEh);
var
i: integer;
begin
// 優(yōu)化GRID的寬度
for i := 0 to TDBGridEh(AGrid).Columns.count - 1 do
THackDBGridEH(AGrid).OptimizeSelectedColsWidth(TDBGridEh(AGrid).Columns[i]);
end;


從ehlib 3.0開(kāi)始,DBGridEH的OptionEh中就多了一個(gè)dbgDblClickOptimizeColWidth選項(xiàng),設(shè)為true,就可以雙擊一個(gè)標(biāo)題的右邊線,自動(dòng)此列的寬度.
但是我想一次性實(shí)現(xiàn)整個(gè)grid的自動(dòng)寬度,卻沒(méi)有找到相就的方法(真的有可能是我沒(méi)有找到,如果本身就有的話請(qǐng)一定要用郵件通知我喔),所以就自已寫(xiě)了一個(gè),用起來(lái)還可以,數(shù)據(jù)量大的時(shí)候就會(huì)有些慢呢!
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
轉(zhuǎn)載DBGrid和DBGridEH
DbgirdEh的一些用法
把DBGrid導(dǎo)出到Excel表格(支持多Sheet)
c builder 6.0 將DBGrid中的數(shù)據(jù)導(dǎo)出到Word和Excel
DBGridEh基本操作
用DBGridEh實(shí)現(xiàn)點(diǎn)擊列頭自動(dòng)排序數(shù)據(jù)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服