Cxgrid控件分组标题的修改

c6372830 2013-04-24 05:16:29
如何更改通过Cxgrid控件进行分组后显示的标题. 之前问过是Ehlib,但是没实现,帖子已结.

例图



比如更改红框那一行的分组标题,在后面添加任意文本或数据.
修改为: Company:Action Club (6) 俱乐部

代码比如:原分组标题+任意字符串
...全文
292 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
c6372830 2013-04-26
  • 打赏
  • 举报
回复
没什么分了,全加上去了.
c6372830 2013-04-26
  • 打赏
  • 举报
回复
一会尝试下. 感谢simonhehe一直耐心回答的问题,谢谢,先结贴
simonhehe 2013-04-26
  • 打赏
  • 举报
回复
满足了lz需求 delphi XE下测试通过
{示例说明:
cxgrdbndtblvw : cxgrid的view名称
  含两列  company, type
}
procedure TForm15.cxgrdbndtblvwCustomDrawGroupCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableCellViewInfo; var ADone: Boolean);
var
  FBounds: TRect;
  sGroupName: string;            //分组行显示的标题
  i, iChildCount: Integer;
begin
  iChildCount := 0;

  //获得当前分组的下级数量
  for i := 0 to cxgrdbndtblvw.DataController.RecordCount - 1 do
  begin
    if VarToStr(AViewInfo.GridRecord.Values[0]) = VarToStr(cxgrdbndtblvw.DataController.Values[i, 0]) then
    begin
      inc(iChildCount);
      sGroupName := cxgrdbndtblvw.DataController.Values[i, 1];      //取type列的名字作为分组行标题的一部分
    end;
  end;

  //格式化分组行
  sGroupName := Format('>> %s:%s(%d)%s', [
    cxgrdbndtblvw.GroupedColumns[0].Caption,
    AViewInfo.GridRecord.Values[0],
    iChildCount,
    sGroupName
  ]);

  //打印分组行
  FBounds := AViewInfo.Bounds;
  ACanvas.FillRect(FBounds);
  OffsetRect(FBounds, 25, 0);

  ACanvas.Font.Style := [fsBold];
  ACanvas.DrawTexT(sGroupName, FBounds, cxAlignLeft or cxAlignVCenter or cxDontClip);
  ADone := True;
end;
火龙岛主 2013-04-26
  • 打赏
  • 举报
回复
分组的内容取决于数据库资料的内容,查询数据的时候你加入所需的中文就可以了。
c6372830 2013-04-25
  • 打赏
  • 举报
回复
您好,我是想每条分组行显示的内容是不一样的. 比如 Company:Action Club (6) 俱乐部 下一个分组行显示 Company:amusement (6) 游乐场 就是添加的字符串根据分组Company字段的值而变更
simonhehe 2013-04-24
  • 打赏
  • 举报
回复
双击cxgrid, 在弹出界面中 summary->groups->summaryItems, 可以设置前驱/后驱字符
simonhehe 2013-04-24
  • 打赏
  • 举报
回复
http://bbs.csdn.net/topics/390435914 这个帖子中, 已经说了cxgrid的实现方法了...

2,495

社区成员

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

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