zoukankan      html  css  js  c++  java
  • Delphi LiveBindings如何绑定一个对象(转)

    原文 http://www.malcolmgroves.com/blog/?p=1084

    一、新建VCL工程加入TAdapterBingSource控件

    二、定一个TPerson类 

    MyPerson : TPerson;
     TPerson = class
      private
        FAge: Integer;
        FLastname: string;
        FFirstname: string;
      public
        constructor Create(const Firstname, Lastname : string; Age : Integer); virtual;
        property Firstname : string read FFirstname write FFirstname;
        property Lastname : string read FLastname write FLastname;
        property Age : Integer read FAge write FAge;
      end;

    三、双击并加入事件代码

    1.创建一个对象实列Person

    2.创建一个BindSourceAdapter

    • self,   指定TObjectBindSource的归属
    • MyPerson,需要邦定对象实例
    • True,是否自动释放,如果否则False 默认值为True
    procedure TForm4.AdapterBindSource1CreateAdapter(Sender: TObject;
      var ABindSourceAdapter: TBindSourceAdapter);
    begin
        MyPerson :=TPerson.Create('test','test1', 13);
        ABindSourceAdapter := TObjectBindSourceAdapter<TPerson>.Create(Self, MyPerson, True);
    end;

    四、放一个TStringGrid对象 在Events LiveBindings点击BindVisually

    点击运行

  • 相关阅读:
    Mysql自定义函数总结
    MySQL的基本函数
    Mysql存储过程总结
    Mysql触发器总结
    Mysql索引总结(二)
    Mysql索引总结(一)
    Mysql游标使用
    别人的博客,留待后看
    mysql外键约束总结
    mysql视图总结
  • 原文地址:https://www.cnblogs.com/pengshaomin/p/3038565.html
Copyright © 2011-2022 走看看