惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
D
DataBreaches.Net
雷峰网
雷峰网
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Engineering at Meta
Engineering at Meta
月光博客
月光博客
V
Visual Studio Blog
美团技术团队
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
博客园 - 【当耐特】
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东

博客园 - delphi中间件

postgresql建库建表脚本 ubuntu配置postgresql远程访问 ubuntu安装postgresql数据库 delphi 面向模型编程 array of TVarRec core.recordModel.pas 使用泛型序列结构体 DDD建模指导 rabbitMQ VS mqtt redis流的应用场景 redis消费者组 redis流的操作命令 领域服务与领域事件 业务规则和模型 限界上下文与统一语言 领域驱动 mqtt即时通讯 ActiveRecord ORM RAD(速成应用开发) unigui插件框架 工厂流水线式自动生产UNIGUI WEB软件 动态生成unidbgrid 单据工厂 用json元数据填充模板 mormot2 ORM rest vs jsonrpc SSE技术详解:使用 HTTP 做服务端数据推送应用的技术 http持久连接 json-rpc 2.0 MCP服务器
delphi cs\web一种统一的界面风格 - delphi中间件 - 博客园
delphi中间件 · 2026-05-13 · via 博客园 - delphi中间件
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.