博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
表格内嵌编辑控件
阅读量:6945 次
发布时间:2019-06-27

本文共 1727 字,大约阅读时间需要 5 分钟。

 
在DBGrid 中嵌入一个 DBComboBox1
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);
begin
if (Field.FieldName = DBComboBox1.DataField ) then
begin
DBComboBox1.Left := Rect.Left+ DBGrid1.Left;
DBComboBox1.Top := Rect.Top +DBGrid1.top;
DBComboBox1.Width := Rect.Right - Rect.Left;
DBComboBox1.Height := Rect.Bottom - Rect.Top;
DBComboBox1.Visible := True;
end;
end;
cxgrid:
procedure TMycxGrid.ColumnDrawCell(Sender: TcxCustomGridTableView;
  ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
  var ADone: Boolean);
var
  g: TcxGrid;
  c: TMyDBComboBox;
  d: TMyDBComboButtonEdit;
  e: TMyDBBitBtn;
  FieldName: string;
  procedure _SetControl(Value: TWinControl);
  begin
    g := TcxGrid(TcxGridDBTableView(Sender).GetParentComponent);
    Value.Left := AViewInfo.TextAreaBounds.Left + g.left;
    Value.Top := AViewInfo.TextAreaBounds.Top + g.Top;
    Value.Width := AViewInfo.TextAreaBounds.Right - AViewInfo.TextAreaBounds.left;
    Value.Height := AViewInfo.TextAreaBounds.Bottom - AViewInfo.TextAreaBounds.top;
    Value.Visible := True;
  end;
begin
  if AViewInfo.Editing then
  begin
    FieldName := LowerCase(TcxGridDBTableView(Sender).Columns[AViewInfo.Item.ID].Caption);
    if fBindControl is TMyDBComboBox then
    begin
      c := fBindControl as TMyDBComboBox;
      if LowerCase(c.DataField) = FieldName then
        _SetControl(c)
      else c.Visible := False;
    end else if fBindControl is TMyDBComboButtonEdit then
    begin
      d := fbindcontrol as TMyDBComboButtonEdit;
      if LowerCase(d.DataField) = FieldName then
        _SetControl(d)
      else d.Visible := False;
    end else if FBindControl is TMyDBBitBtn then
    begin
      e := fbindcontrol as TMyDBBitBtn;
      if LowerCase(e.DataField) = FieldName then
        _SetControl(e)
      else e.Visible := False;
    end;
  end;
end;

转载地址:http://kdenl.baihongyu.com/

你可能感兴趣的文章
选择交换机和选择路由器的主要技能指标
查看>>
as3 用StyleSheet css 设置文本样式
查看>>
Bootstrap3 代码-变量
查看>>
转 数据库常用命令
查看>>
android--显式跳转和隐式跳转
查看>>
PHP和JS判断访问客户端的是PC还是移动设备
查看>>
FreeCodeCamp:Chunky Monkey
查看>>
MySQL数据库/数据表/字段--字符集查看/修改
查看>>
JavaScript核心语法学习部分(五)
查看>>
Error: php71w-common conflicts with php-common-5.4.16-46.el7.x86_64
查看>>
初探 回文树
查看>>
SQL根据列值查询表
查看>>
php 操作webservice实例
查看>>
Python初学练习03:简易ATM系统-前端
查看>>
浮点数到整数的快速转换
查看>>
cacti服务器处理
查看>>
我的友情链接
查看>>
搭建zabbix遇到的问题
查看>>
Linux搭建quota
查看>>
ubuntu下安装redmine及其邮件发送的配置
查看>>