列  

解决:

      <aColumn>.GroupIndex   :=   -1;  

      <aColumn>.Visible   :=   True;

****************************************************************************

39 保存修改到数据库

解决:

procedure   <aForm>.FormClose(Sender:   TObject;   var   Action:   TCloseAction);  

begin  

if   (<aGrid>.FocusedView <> nil)

and   (<aGrid>.FocusedView.DataController.EditState <> []) then  

          <aGrid>.FocusedView.DataController.Post;  

end;

****************************************************************************

40 设置内置右键菜单

解决:

内置右键菜单包括二个菜单:cxGridStdHeaderMenu,   TcxGridStdFooterMenu

[delphi] view
plain
copy

  1. uses   cxGridStdPopupMenu;
  2. procedure   TForm1.cxGridPopupMenu1Popup(ASenderMenu:   TComponent;
  3. AHitTest:   TcxCustomGridHitTest;   X,   Y:   Integer;   var   AllowPopup:   Boolean);
  4. begin
  5. if   ASenderMenu   is   TcxGridStdHeaderMenu   then
  6. TcxGridStdHeaderMenu(ASenderMenu).OnPopup   :=   StdHeaderMenuPopup;
  7. end;
  8. procedure   TForm1.StdHeaderMenuPopup(Sender:   TObject);
  9. var
  10. I:   Integer;
  11. begin
  12. with   TcxGridStdHeaderMenu(Sender).Items   do
  13. for   I   :=   0   to   Count   -   1   do
  14. if   Items[I].Caption   =   'Group   By   Box'   then
  15. begin
  16. Items[I].Enabled   :=   False;
  17. System.Break;
  18. end
  19. end;

****************************************************************************

41 得到选中记录的值

解决:

[delphi] view
plain
copy

  1. 1)   View.DataController.DataModeController.GridMode   =   False时
  2. RecIdx   :=   View.Controller.SelectedRecords[i].RecordIndex;
  3. ColIdx   :=   View.DataController.GetItemByFieldName(AFieldName).Index;
  4. OutputVal   :=   View.DataController.Values[RecIdx,   ColIdx];
  5. //RecID   :=   View.DataController.GetRecordId(RecIdx);
  6. //OutputVal   :=   ADataSet.Lookup(View.DataController.KeyFieldNames,   RecID,   AFieldName);
  7. 2)   View.DataController.DataModeController.GridMode   =   True时
  8. Bkm   :=   View.DataController.GetSelectedBookmark(ASelectedRecordIndex);
  9. if   ADataSet.BookmarkValid(TBookmark(Bkm))   then
  10. begin
  11. ADataSet.Bookmark   :=   TBookmark(Bkm);
  12. OutputVal   :=   ADataSet.FieldByName(AFieldName).Value;
  13. end;
  14. View.BeginUpdate;
  15. View.DataController.BeginLocate;
  16. try
  17. //   make   changes   here…
  18. finally
  19. View.DataController.EndLocate;
  20. View.EndUpdate;
  21. end;

****************************************************************************

42 在GridMode禁用内置的右键Footer菜单

解决:

uses   cxGridStdPopupMenu;  

   

procedure   cxGridPopupMenuOnPopup(...)  

begin  

      if   (ASenderMenu   is   TcxGridStdFooterMenu)   and  

              <GridView>.DataController.DataModeController.GridMode   then  

          AllowPopup   :=   False;  

end;

****************************************************************************

43 主从表任何时候只能展开一个组

解决:

[delphi] view
plain
copy

  1. procedure   TForm1.ADetailDataControllerCollapsin(  ADataController:  TcxCustomDataController;
  2. ARecordIndex:   Integer;  var   AAllow:   Boolean);
  3. var
  4. I:   Integer;
  5. C:   Integer;
  6. begin
  7. AAllow   :=   False;
  8. C   :=   0;
  9. for   I   :=   0   to   ADataController.RecordCount   -   1   do
  10. begin
  11. if   ADataController.GetDetailExpanding(I)   then
  12. Inc(C);
  13. if   C   >   1   then
  14. AAllow   :=   True;
  15. end;
  16. end;
  17. procedure   TForm1.ADetailDataControllerExpanding(
  18. ADataController:   TcxCustomDataController;   ARecordIndex:   Integer;
  19. var   AAllow:   Boolean);
  20. begin
  21. ADataController.CollapseDetails;
  22. end;
  23. procedure   TForm1.FormCreate(Sender:   TObject);
  24. begin        cxGrid1DBTableView1.DataController.OnDetailExpanding:=ADetailDataControllerExpanding;         cxGrid1DBTableView1.DataController.OnDetailCollapsing:=ADetailDataControllerCollapsing;
  25. end;
  26. ****************************************************************************
  27. 44 动态创建层次(Level)和视图(View)
  28. 解决:
  29. var
  30. Grid:   TcxGrid;
  31. Level:   TcxGridLevel;
  32. View:   TcxGridDBTableView;
  33. begin
  34. //   Creates   a   Grid   instance
  35. Grid   :=   TcxGrid.Create(SomeOwner);
  36. Grid.Parent   :=   SomeParent;
  37. //   Creates   a   Level
  38. Level   :=   Grid.Levels.Add;
  39. Level.Name   :=   'SomeLevelName';
  40. //   Creates   a   View
  41. View   :=   Grid.CreateView(TcxGridDBTableView)   as   TcxGridDBTableView;
  42. View.Name   :=   'SomeViewName';
  43. //   …   and   binds   it   to   the   Level
  44. Level.GridView   :=   View;
  45. //   Hooks   up   the   View   to   the   data
  46. View.DataController.DataSource   :=   SomeDataSource;
  47. //   …   and   creates   all   columns
  48. View.DataController.CreateAllItems;
  49. end;

****************************************************************************

45 获得Group   Footer合计行对应的记录

解决:

[delphi] view
plain
copy

  1. procedure   TForm1.cxGrid1DBTableView1CustomDrawFooterCell(
  2. Sender:   TcxGridTableView;   ACanvas:   TcxCanvas;
  3. AViewInfo:   TcxGridColumnHeaderViewInfo;   var   ADone:   Boolean);
  4. var
  5. ALevel,   ADataGroupIndex:   Integer;
  6. AGridRecord,   AGroupRecord:   TcxCustomGridRecord;
  7. begin
  8. if   AViewInfo   is   TcxGridRowFooterCellViewInfo   and    //   Row   footer
  9. (TcxGridDBColumn(AViewInfo.Column).DataBinding.FieldName   =   'Area')   then     //   Area   column
  10. begin
  11. AGridRecord:=   TcxGridRowFooterCellViewInfo(AViewInfo).GridRecord;
  12. ALevel:= TcxGridRowFooterCellViewInfo(AViewInfo).Container.GroupLevel;
  13. ADataGroupIndex:=Sender.DataController.Groups.DataGroupIndexByRowIndex[AGridRecord.Index];
  14. if   ADataGroupIndex   <>   -1   then
  15. begin
  16. AGroupRecord   :=   AGridRecord;
  17. while   AGroupRecord.Level   <>   ALevel   do
  18. AGroupRecord   :=   AGroupRecord.ParentRecord;
  19. AViewInfo.Text   :=   AGroupRecord.DisplayTexts[0];
  20. end;
  21. end;
  22. end;

****************************************************************************

46 访问过滤之后的记录

解决:

var  

      I:   Integer;  

begin  

      Memo1.Lines.Clear;  

      with   cxGrid1DBTableView1.DataController   do  

          for   I   :=   0   to   FilteredRecordCount   -   1   do  

              Memo1.Lines.Add(DisplayTexts[FilteredRecordIndex[I],   0]);  

end;

****************************************************************************

47 获得单元的Font

解决:

cxGrid1DBTableView1.ViewInfo.RecordsViewInfo.Items[1].GetCellViewInfoByItem(  

      cxGrid1DBTableView1Company).EditViewInfo.Font;

****************************************************************************

48 根据Level名称找到Level对象

解决:

[delphi] view
plain
copy

  1. function   GetLevelByName(AGrid:   TcxGrid;   ALevelName:   string):   TcxGridLevel;
  2. function   LoopThroughLevels(ALevel:   TcxGridLevel;   ALevelName:   string):   TcxGridLevel;
  3. var
  4. I:   Integer;
  5. begin
  6. Result   :=   nil;
  7. for   I   :=   0   to   ALevel.Count   -   1   do
  8. begin
  9. if   ALevel[I].Name   =   ALevelName   then
  10. begin
  11. Result   :=   ALevel[I];
  12. Exit;
  13. end;
  14. if   ALevel[I].Count   >   0   then
  15. begin
  16. Result   :=   LoopThroughLevels(ALevel[I],   ALevelName);
  17. if   Result   <>   nil   then
  18. Exit;
  19. end;
  20. end;
  21. end;
  22. var
  23. I:   Integer;
  24. begin
  25. Result   :=   nil;
  26. for   I   :=   0   to   AGrid.Levels.Count   -   1   do
  27. begin
  28. if   AGrid.Levels[I].Name   =   ALevelName   then
  29. begin
  30. Result   :=   AGrid.Levels[I];
  31. Exit;
  32. end;
  33. if   AGrid.Levels[I].Count   >   0   then
  34. begin
  35. Result   :=   LoopThroughLevels(AGrid.Levels[I],   ALevelName);
  36. if   Result   <>   nil   then
  37. Exit;
  38. end;
  39. end;
  40. end;

****************************************************************************

49 指定Filter   Builder打开/保存过滤文件的默认路径

解决:

uses  

      ...,   cxFilterControlDialog;  

   

procedure   TForm.GridView1FilterControlDialogShow(  

      Sender:   TObject);  

begin  

      TfmFilterControlDialog(Sender).OpenDialog.InitialDir   :=   'D:/'  

end;

Delphi CxGrid 汇总(3)的更多相关文章

  1. Delphi CxGrid 汇总(4)

    1.     CxGrid汇总功能 ① OptionsView-Footer设置为True,显示页脚   ② CxGrid的Summary选项卡定义要汇总的列和字段名及汇总方式,Footer选项卡定义 ...

  2. Delphi CxGrid 汇总(2)

    17. 怎样设计多表头的cxGrid? 解决:cxGrid可以解决如下的表头: --------------------------------- | 说明1 | 说明2 | ------------ ...

  3. delphi cxgrid 使用方法

    delphi cxgrid 使用方法1.绑定数据 方法 cxGrid1DBTableView1.DataController.DataSource:=DataSource12.去掉"Drag ...

  4. 关于Delphi cxGrid主从表中从表只能编辑第一条记录的问题

    在Delphi cxGrid主从表中从表只能编辑第一条记录,这个问题是由于设置主从关联字段错误造成的. 从表DBtableView2的keyfieldnames,DetailKeyFieldNames ...

  5. Delphi cxGrid使用汇总(一)

    1. 去掉cxGrid中台头的Box解决:在tableview1的ptionsview的groupbybox=false; 2.统计功能解决:(1) tableview1. tableview1的op ...

  6. Delphi cxGrid –--> RecordIndex out of Range

    delphi 导出数据时常常出现这样一个错误 < RecordIndex out of Range > 处理办法: 设定 cxGridDBTableView 的 GridModeBuffe ...

  7. Delphi - cxGrid颜色显示相关设置

    1:单元格的值满足某个条件时,该单元格所在整行颜色设置整行字体设置 选中cxGridDBTableView,单击F11调出属性配置面板,在Events中双击OnCustomDrawCell后双击编辑重 ...

  8. Delphi - cxGrid内容xlsx、xls、csv格式导出

    .xls格式导出,uses中添加cxGridExportLink 代码如下: function SaveToExcel(gridMain: TcxGrid; FileName: string): st ...

  9. Delphi - cxGrid设定合并单元格

    在cxGrid中选中需要合并的字段,单击F11调出属性控制面板,展开Options,设置CellMerging的Value为True.

随机推荐

  1. Oracle 版本历史

    1.数据库在项目开发里面,大多数都使用Oracle,什么8i,9i,10G,11g等,一直认为数据库版本的升级对于开发一个系统的开发人员来书,不是什么重要的事,我仅仅关注数据库的表结构以及存储过程或者 ...

  2. Arch时间校准

    sudo ln -s /usr/share/zoneinfo/UTC /etc/localtime sudo hwclock --systohc --utc sudo timedatectl set- ...

  3. DP三角形

    Hrbust1038  http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1038 // ...

  4. jmeter接口自动化,你敢想,我敢玩

    飞测说:大家好,我是黑夜小怪,今天我又来了分享了.最近用jmeter比较多,做过自动化测试的都知道,我们脚本和数据维护是你十分头疼的事情,刚好黑夜小怪我最近接触到一个项目的接口测试,今天我们一起分享下 ...

  5. 业务gis 搭建一个skyline 的js模板 (一)

    刚刚我们说的是二维的系统,如果要展示三维,我们是不是也需要这样,答案是必须的,是一定要,如果你是基于skyline做三维开发,业务开发人员要去搞那套api估计要吐血,所以我们必须得封装起来,这里不介绍 ...

  6. PostMessage与SendMessage的区别(二)

    在做基于窗口的Windows程序的时候,我们避免不了要向窗口发送消息,有两种方式,一种是PostMessage,另外一种是SendMessage.关于这两个宏,我是通过狠狠的看MSDN才搞明白的,那里 ...

  7. TCP/IP详解学习笔记(10)-- DNS:域名系统

    1.DNS      DNS 是计算机域名系统(Domain Name System 或Domain Name Service) 的缩写,它是由解析器以及域名服务器组成的.域名服务器是指保存有该网络中 ...

  8. JavaScript之数组循环 forEach 循环输出数组元素

    var arrayAll = []; arrayAll.push(1); arrayAll.push(2); arrayAll[arrayAll.length] = 3; arrayAll[array ...

  9. 【spring 7】spring和Hibernate的整合:声明式事务

    一.声明式事务简介 Spring 的声明式事务管理在底层是建立在 AOP 的基础之上的.其本质是对方法前后进行拦截,然后在目标方法开始之前创建或者加入一个事务,在执行完目标方法之后根据执行情况提交或者 ...

  10. HDOJ1010(BFS)

    //为什么bfs不行呢,想不通 #include<cstdio>#include<cstring>#include<queue>using namespace st ...