一、排序功能:(原文链接:http://www.tansoo.cn/?p=401)
首先在uses节中根据你选用的数据集引用对应的 EhLibXXX (EhLibADO, EhLibCDS…)
然后再设置下面几个DBGridEh控件的属性:
1 | procedure TForm1.FormCreate(Sender: TObject); |
5 | DBGridEh1.SortLocal := True; |
6 | DBGridEh1.OptionsEh := DBGridEh1.OptionsEh + [dghAutoSortMarking]; |
7 | for I := 0 to DBGridEh1.Columns.Count - 1 do |
8 | DBGridEh1.Columns[I].Title.TitleButton := True; |
二、过滤功能:
具体设置很简单,如下:
1 | DBGridEh1.STFilter.Visible := True; |
2 | DBGridEh1.STFilter.Local := True; |
如果想在下拉列表中加入自定义过滤条件,可以在相应列的OnFillSTFilterListValues事件中加入:
1 | procedure TForm3.DBGridEh1Columns1FillSTFilterListValues( |
2 | Sender: TCustomDBGridEh; Column: TColumnEh; Items: TStrings; |
3 | var Processed: Boolean); |

三、自动搜索:
该搜索框可实现自动搜索并过滤。
1 | DBGridEh1.SearchPanel.Enabled := True; |
2 | DBGridEh1.SearchPanel.FilterOnTyping := True; |