TDBGridEh终于可以用了,现在想点击标题栏排序,可是从网上拷了很多代码,都不能用,谁能帮忙

山水无言 2010-06-02 05:03:09
如题
...全文
128 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
okgxs 2010-06-03
  • 打赏
  • 举报
回复
引用完单元,设置属性可以排序了
okgxs 2010-06-03
  • 打赏
  • 举报
回复
没错需要引用一个 单元
kv2002 2010-06-03
  • 打赏
  • 举报
回复
再引用 EhlibADO 单元就可以了。

{*******************************************************}
{ Add this unit to 'uses' clause of any unit of your }
{ project to allow TDBGridEh to sort data in }
{ TADOQuery automatically after sorting markers }
{ will be changed. }
{ TSQLDatasetFeaturesEh will try to find line in }
{ TADOQuery.SQL string that begin from 'ORDER BY' phrase}
{ and replace line by 'ORDER BY FieldNo1 [DESC],....' }
{ using SortMarkedColumns. }
{*******************************************************}
musa2008 2010-06-03
  • 打赏
  • 举报
回复
用的是ADO,在DBGridEh的OnTitleBtnClick事件里:
if DataModule1.ds_sql.Active then
begin
if column.Title.SortMarker=smdowneh then
DataModule1.ds_sql.Sort :=column.FieldName
else
DataModule1.ds_sql.Sort :=column.FieldName +' DESC';
end;
musa2008 2010-06-03
  • 打赏
  • 举报
回复
用的是ADO,在DBGridEh的OnTitleBtnClick事件里:
if DataModule1.ds_sql.Active then
begin
if column.Title.SortMarker=smdowneh then
DataModule1.ds_sql.Sort :=column.FieldName
else
DataModule1.ds_sql.Sort :=column.FieldName +' DESC';
end;
liaobo 2010-06-03
  • 打赏
  • 举报
回复
private
{ Private declarations }
sort: string;


procedure TForm1.DBGridEh2TitleClick(Column: TColumnEh);
begin
if SORT = 'DESC' then
begin
Sort := 'ASC';
Column.Title.SortMarker := smUpEh;
end
else
begin
sort := 'DESC';
Column.Title.SortMarker := smDownEh;
end;
ADOTable1.Sort := Column.FieldName + ' ' + sort;
end;
山水无言 2010-06-03
  • 打赏
  • 举报
回复
谁有点击TDBGridEh标题排序的可用的代码,我在网上找了许多,试了之后都不会排序
山水无言 2010-06-02
  • 打赏
  • 举报
回复
我用的是ADO。
上面的方法我都试了,点完Title之后,Title上会出现一个正三角或倒三角符号,但是实际上没有排序
kv2002 2010-06-02
  • 打赏
  • 举报
回复
OptionsEh中的 dghAutoSortMarking 设置为True
字段的Title中的TitleButton设置为True
记得好像要引用相应的单元 根据ADO、BDE不同吧
starluck 2010-06-02
  • 打赏
  • 举报
回复
看你写的是什么样的?

你用的ADO还是BDE?
SuperTitan001 2010-06-02
  • 打赏
  • 举报
回复
用adoquery.sort
SuperTitan001 2010-06-02
  • 打赏
  • 举报
回复
用adoquery.sort

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧