列  
解决:
      <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 plaincopy
  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 plaincopy
  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 plaincopy
  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 plaincopy
  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 plaincopy
  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;

转载于:https://www.cnblogs.com/jupt/p/3922932.html

Delphi CxGrid 汇总(3)相关推荐

  1. Delphi CxGrid 用法详解

    1. 去掉cxgrid中抬头的box,在tableview1的ptionsview的groupbybox=false; 2. 在GRID footer 中加入sum(列),tableview1的opt ...

  2. delphi cxgrid 增加选择框

    查了网上很多资料没有说明,都是各种多选方法,乱七八糟. 以前用dxdbgrid也没这么麻烦.我觉得CXgrid一定有开启的方法,所以经过不停试属性,终于试出来了. cxgrid是自带选择框的表格,开启 ...

  3. delphi cxgrid读取本地image_技术讨论 | PHP本地文件包含漏洞GetShell

    序言 让我们突破重重苛刻环境GetShell,文中有以phpmyadmin包含漏洞做演示. PS:本文仅用于技术讨论与分析,严禁用于任何非法用途,违者后果自负. 漏洞背景 当您在发现PHP本地文件包含 ...

  4. delphi cxgrid导出excel去除货币符号

    版本 : devexpress 13.1.4 打开 包在ExpressExportLibary目录中.  修改FCells.SetCellDataCurrency为FCells.SetCellData ...

  5. Delphi 精选文章地址

    Delphi 三层开发 ************   http://blog.csdn.net/lailai186/article/category/1396968 Delphi CxGrid 汇总 ...

  6. Delph cxGrid操作

    Delphi Cxgrid获取选中行列,排序规则,当前正在编辑的单元格内的值 cxGrid1DBTableView1.Controller.FocusedRowIndex 当前行号 cxGrid1DB ...

  7. DevExpressVCL控件之DevExpress

    以下皆借用各位大佬: TcxFilterControl:过滤器控件,根据cxgrid的filterControl建立强大灵活的过滤器 - westsoft - 博客园 TcxTabControl:选项 ...

  8. cxGrid使用汇总4

    49指定Filter   Builder打开/保存过滤文件的默认路径 解决: uses         ...,   cxFilterControlDialog;       procedure   ...

  9. 最全面的常用Delphi第三方控件汇总—报表、图表、界面、数据库等

    有网友问我常用的控件及功能.我先大概整理一下,以后会在文章里面碰到时再仔细介绍. 报表图表方面: TeeChart Pro 在delphi 的图形显示方面目前唯一的选择,虽然从delphi 3 就随d ...

最新文章

  1. Linux下stat + 文件名后, Access,Modify,Change的含义
  2. 通俗易懂:图卷积神经网络入门详解
  3. MySQL 5.7 并行复制实现原理与调优
  4. python有什么作用-大数据学习之python语言有什么作用?
  5. tkinter中的canvas的边框问题
  6. BUUCTF(pwn)mrctf2020_easyoverflow
  7. LVM---基本创建和使用
  8. acquireQueued
  9. 大一大学计算机考试难吗,新生必看!大一期间必考的3个证书,不考后悔,越拖越难考!...
  10. RowVersion字段从SqlServer到PostgreSQL的迁移
  11. 大自然里,隐藏着最美妙的数学
  12. 电脑c语言怎么调出来的,c语言系统源代码_C语言判断系统版本的代码怎样将值调出来啊...
  13. Java8 stream().map()将对象转换为其他对象
  14. 接口定义【领域对象】
  15. 框架页面中,从子页面刷新父页面问题解决
  16. 电脑网页截屏怎么截长图?借助Safari对整个网页进行长截图
  17. 从事汽车电子软件开发需要什么技能?
  18. Matlab转C/C++/Cmex文件加速运行方法
  19. 计算机一级证件照尺寸,照相馆不会告诉你的哪些事:常用证件照尺寸汇总
  20. 电话程控交换机安装经验

热门文章

  1. 分享jQuery的常用技巧12招
  2. Linux命令学习-mv命令
  3. System.LazyT 延迟加载
  4. 【javascript】javascript设计模式mixin模式
  5. mybatis逆向工程生成的Example类的使用
  6. 服务器上装了安全狗后远程链接不上怎么解决
  7. 获取本机MSSQL保存凭证
  8. Linux--内存结构
  9. my wordpress
  10. eclipse中hadoop2.3.0环境部署及在eclipse中直接提交mapreduce任务