















unit Unit1; interface uses core.json, Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage, cxEdit, cxNavigator, dxDateRanges, dxScrollbarAnnotations, Data.DB, cxDBData, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.VCLUI.Wait, FireDAC.Phys.MSSQLDef, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet, FireDAC.Comp.Client, FireDAC.Phys.ODBCBase, FireDAC.Phys.MSSQL, cxGridLevel, cxClasses, cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, cxButtonEdit, cxGeometry, dxFramedControl, cxContainer, cxTextEdit, cxDBEdit, dxPanel, Vcl.StdCtrls; type TForm1 = class(TForm) cxGrid1DBTableView1: TcxGridDBTableView; cxGrid1Level1: TcxGridLevel; cxGrid1: TcxGrid; FDConnection1: TFDConnection; FDPhysMSSQLDriverLink1: TFDPhysMSSQLDriverLink; FDQuery1: TFDQuery; DataSource1: TDataSource; cxGrid1DBTableView1unitid: TcxGridDBColumn; cxGrid1DBTableView1unitname: TcxGridDBColumn; cxGrid1DBTableView1Column1: TcxGridDBColumn; dxPanel1: TdxPanel; cxDBTextEdit1: TcxDBTextEdit; Label1: TLabel; dxPanel2: TdxPanel; Label2: TLabel; cxDBTextEdit2: TcxDBTextEdit; procedure cxGrid1DBTableView1Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure grid; procedure item; private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.cxGrid1DBTableView1Column1PropertiesButtonClick( Sender: TObject; AButtonIndex: Integer); begin case AButtonIndex of 0: ShowMessage('删除'); 1: ShowMessage('修改'); end; end; procedure TForm1.grid; begin cxGrid1DBTableView1.OptionsView.GridLines := glHorizontal;//只显示横线 var col: TcxGridDBColumn := cxGrid1DBTableView1.CreateColumn; //操作列 col.Caption := '操作'; col.PropertiesClassName := 'TcxButtonEditProperties'; TcxButtonEditProperties(col.Properties).ViewStyle := vsButtonsAutoWidth; col.Properties.OnButtonClick := cxGrid1DBTableView1Column1PropertiesButtonClick; col.Options.ShowEditButtons := isebAlways; col.Width := 74; //操作按钮 var btn: TcxEditButton := col.Properties.Buttons.Add; btn.Caption := '删除'; btn.Kind := bkText; //其它列 var col2: TcxGridDBColumn := cxGrid1DBTableView1.CreateColumn; col2.Caption := '条码'; col2.DataBinding.FieldName := 'unitid'; col2.Width := 62; end; procedure TForm1.item; begin var colNum: Integer := 2; //2列 var pnlWidth: Integer := 300; var pnlHeight: Integer := 24; var LeftSpace: Integer := 38; var TopSpace: Integer := 7; var captionWidth: Integer := 60; var lja: JA; for var i: Integer := 0 to lja.Count - 1 do begin var obj: JO := lja.Items[i] as JO; var iCol: Integer := i mod colNum; var left: Integer; case iCol of 0: left := LeftSpace; 1: left := LeftSpace + pnlWidth + LeftSpace; end; var rowNum: Integer := i div colNum; var top: Integer := rowNum * pnlHeight + TopSpace; var pnlMaster: TdxPanel; var pnl: TdxPanel := TdxPanel.Create(pnlMaster); pnl.Parent := pnlMaster; pnl.Left := left; pnl.Top := top; pnl.Width := pnlWidth; pnl.Height := pnlHeight; pnl.Frame.Color := clSilver; pnl.Frame.Borders := [bBottom]; var lbl: TLabel := TLabel.Create(pnl); lbl.Parent := pnl; lbl.Align := alLeft; lbl.Alignment := taCenter; lbl.Caption := obj.S['caption']; if obj.S['component'] = 'dbedit' then begin var edt: TcxDBTextEdit := TcxDBTextEdit.Create(pnl); edt.Parent := pnl; edt.Align := alRight; edt.Width := pnl.Width - captionWidth; edt.Style.BorderStyle := ebsNone; edt.Style.Color := clBtnFace; edt.DataBinding.DataField := obj.S['fieldname']; edt.DataBinding.DataSource := dataSourceM; edt.Properties.ReadOnly := obj.B['readonly']; //选择事件 处理 if SameText(obj.S['onclick'], 'selectshop') then begin end; end; end; end; end.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。