CxGrid 多表头操作代码
来源:互联网 发布:网络空间是 编辑:程序博客网 时间:2024/05/01 21:13
unit UnitPjgl;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, cxStyles, cxCustomData, cxGraphics,
cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel,
cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGrid, ExtCtrls, Buttons, ADODB,
cxGridBandedTableView, cxGridDBBandedTableView, cxTextEdit, cxCalc;
type
TFramePjgl = class(TFrame)
tbcpjgl: TTabControl;
grp1: TGroupBox;
grpOperator: TGroupBox;
lblNewPjDate: TLabel;
pnlList: TPanel;
rbzdSearch: TRadioButton;
rbxlSearch: TRadioButton;
edtSearchIf: TEdit;
btnSearch: TBitBtn;
cbbOperatorType: TComboBox;
cbbJsfs: TComboBox;
edtContext: TEdit;
btnSwitch: TBitBtn;
btnSave: TBitBtn;
qryPjList: TADOQuery;
dsPjList: TDataSource;
cxgrd1: TcxGrid;
bandtvfilms: TcxGridDBBandedTableView;
lvfilms: TcxGridLevel;
bandtvfilmszddm: TcxGridDBBandedColumn;
bandtvfilmszm: TcxGridDBBandedColumn;
bandtvfilmszs: TcxGridDBBandedColumn;
bandtvfilmsa: TcxGridDBBandedColumn;
bandtvfilmsb: TcxGridDBBandedColumn;
bandtvfilmsc: TcxGridDBBandedColumn;
bandtvfilmsd: TcxGridDBBandedColumn;
bandtvfilmse: TcxGridDBBandedColumn;
bandtvfilmsf: TcxGridDBBandedColumn;
bandtvfilmsg: TcxGridDBBandedColumn;
bandtvfilmsh: TcxGridDBBandedColumn;
bandtvfilmsi: TcxGridDBBandedColumn;
bandtvfilmsj: TcxGridDBBandedColumn;
bandtvfilmsk: TcxGridDBBandedColumn;
bandtvfilmsl: TcxGridDBBandedColumn;
bandtvfilmsm: TcxGridDBBandedColumn;
bandtvfilmsn: TcxGridDBBandedColumn;
bandtvfilmso: TcxGridDBBandedColumn;
bandtvfilmsp: TcxGridDBBandedColumn;
bandtvfilmsq: TcxGridDBBandedColumn;
bandtvfilmsr: TcxGridDBBandedColumn;
bandtvfilmss: TcxGridDBBandedColumn;
bandtvfilmst: TcxGridDBBandedColumn;
bandtvfilmsu: TcxGridDBBandedColumn;
bandtvfilmsv: TcxGridDBBandedColumn;
bandtvfilmsw: TcxGridDBBandedColumn;
bandtvfilmsx: TcxGridDBBandedColumn;
bandtvfilmsy: TcxGridDBBandedColumn;
bandtvfilmsz: TcxGridDBBandedColumn;
bandtvfilmsFlag: TcxGridDBBandedColumn;
cxstylrpstry1: TcxStyleRepository;
cxgrdtblvwstylshtGridTableViewStyleSheetDevExpress: TcxGridTableViewStyleSheet;
cxstyl1: TcxStyle;
cxstyl2: TcxStyle;
cxstyl3: TcxStyle;
cxstyl4: TcxStyle;
cxstyl5: TcxStyle;
cxstyl6: TcxStyle;
cxstyl7: TcxStyle;
cxstyl8: TcxStyle;
cxstyl9: TcxStyle;
cxstyl10: TcxStyle;
cxstyl11: TcxStyle;
cxstyl12: TcxStyle;
cxstyl13: TcxStyle;
cxstyl14: TcxStyle;
cxStyle1: TcxStyle;
con1: TADOConnection;
btnTbxpj: TBitBtn;
btnUpdatePj: TBitBtn;
procedure tbcpjglChange(Sender: TObject);
private
procedure InitTableTitle;
{ Private declarations }
public
procedure GetConnectionDB(flag:Integer);
{ Public declarations }
end;
implementation
uses UnitMain, PublicFile;
{$R *.dfm}
procedure TFramePjgl.GetConnectionDB(flag:Integer);
begin
if Flag=1 then
begin
try
con1.Connected:=True;
except
HintInfo('连接数据库失败!',2);
end;
end;
end;
procedure TFramePjgl.InitTableTitle;
var
SqlStr:string;
QryTmp:TADOQuery;
i:Integer;
begin
QryTmp:=TADOQuery.Create(Self);
QryTmp.Connection:=con1;
try
SqlStr:='select ''到站''as zddm,''到站''as zddm,''注释''as zs,zsa,zsb,zsc,zsd,zse,zsf,zsg,zsh,zsi,zsj,zsk,zsl,';
SqlStr:=SqlStr+'zsm,zsn,zso,zsp,zsq,zsr,zss,zst,zsu,zsv,zsw,zsx,zsy,zsz,''1'' as bz from pjzsb';
DataFind(SqlStr,QryTmp);
i:=3;
while QryTmp.FieldCount> i do
begin
bandtvfilms.Bands.Items[i-1].Caption:=Trim(QryTmp.Fields[i].AsString);
i:=i+1;
end;
finally
QryTmp.Free;
end;
end;
procedure TFramePjgl.tbcpjglChange(Sender: TObject);
var
Sqlstr:string;
begin
qryPjList.Connection:=con1;
if tbcpjgl.TabIndex=1 then
begin
//cxgrd1.Levels[0].GridView:=tvfilms;
//cxgrd1.Levels[0].GridView:=bandtvfilms; 指定View
InitTableTitle; //动态生成注释表头
Sqlstr:='select * from (select zddm,zm,''里程'' as zs,la as a,lb as b,lc as c,ld as d,le as e,lf as f,lg as g,lh as h,li as i, ';
Sqlstr:=Sqlstr+' lj as j,lk as k,ll as l,lm as m,ln as n,lo as o,lp as p,lq as q,lr as r,ls as s,lt as t,lu as u, ';
Sqlstr:=Sqlstr+' lv as v,lw as w,lx as x,ly as y,lz as z,''1''as Flag from zmpjb ';
Sqlstr:=Sqlstr+' union all select zddm,zm,''客票票价'' as pj,xa,xb,xc,xd,xe,xf,xg,xh,xi,xj,xk,xl,xm,xn,xo,xp,xq,xr,xs,xt,xu,xv,xw,xx,xy,xz,''2''as Flag from zmpjb ';
Sqlstr:=Sqlstr+' union all select zddm,zm,''燃油附加'' as ry,rxa,rxb,rxc,rxd,rxe,rxf,rxg,rxh,rxi,rxj,rxk,rxl,rxm,rxn,rxo,rxp,rxq,rxr, ';
Sqlstr:=Sqlstr+' rxs,rxt,rxu,rxv,rxw,rxx,rxy,rxz,''3''as Flag from zmpjb) aa order by zddm ,flag ';
DataFind(Sqlstr,qryPjList);
end
else if tbcpjgl.TabIndex=0 then
begin
Sqlstr:='select * from (select zddm,zm,''里程'' as zs,la as a,lb as b,lc as c,ld as d,le as e,lf as f,lg as g,lh as h,li as i, ';
Sqlstr:=Sqlstr+' lj as j,lk as k,ll as l,lm as m,ln as n,lo as o,lp as p,lq as q,lr as r,ls as s,lt as t,lu as u, ';
Sqlstr:=Sqlstr+' lv as v,lw as w,lx as x,ly as y,lz as z,''1''as Flag from zmpjb ';
Sqlstr:=Sqlstr+' union all select zddm,zm,''客票票价'' as pj,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,''2''as Flag from zmpjb ';
Sqlstr:=Sqlstr+' union all select zddm,zm,''燃油附加'' as ry,ra,rb,rc,rd,re,rf,rg,rh,ri,rj,rk,rl,rm,rn,ro,rp,rq,rr, ';
Sqlstr:=Sqlstr+' rs,rt,ru,rv,rw,rx,ry,rz,''3''as Flag from zmpjb) aa order by zddm ,flag ';
DataFind(Sqlstr,qryPjList);
end;
end;
end.
- CxGrid 多表头操作代码
- cxGrid去掉表头
- 三步轻松搞定delphi中CXGRID手动添加复表头(多行表头,报表头)
- 三步轻松搞定delphi中CXGRID手动添加复表头(多行表头,报表头)
- Delph cxGrid操作
- POI EXCEL多表头的处理代码
- POI EXCEL多表头的处理代码
- cxgrid
- POI EXCEL多表头的处理代码收藏
- cxGrid多选使用CheckBox
- 关于CListCtrl表头的操作
- 操作组合表头(js)
- easyUI 复杂表头(效果图) &&代码
- easyUI复杂表头(效果图)&&代码
- 一段冻结表头的代码
- 无插件固定表头代码
- 使用cxGrid对数据集进行Sort和Locate操作
- easyui 多表头(复杂表头)
- Format函数的用法
- onClientClick=''return confirm与验证控件冲突问题
- C#中获取计算机信息
- (转载) 改变人生的五句话
- 学习COM编程的好资料
- CxGrid 多表头操作代码
- linux gnome m4
- HTML入门----meta的知识
- DIB--设备无关位图文件
- 中文乱码解决方法
- 设计模式-观察者模式应用
- 一个月后的日期转换
- 编码转换
- History(历史)命令用法 15 例