datatree和数据库绑定的最少代码

页面导航:首页 > 软件编程 > Delphi > datatree和数据库绑定的最少代码

datatree和数据库绑定的最少代码

来源: 作者: 时间:2016-02-05 11:47 【

unit mmslibrarypage;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ImgList, VirtualTrees, ComCtrls, ToolWin, mpToolBar,basicModal,Data

unit mmslibrarypage;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ImgList, VirtualTrees, ComCtrls, ToolWin, mpToolBar,basicModal,DataModal,
  database,myScroll,insertdemon,mysql,newmmsForlibrary;

type
  TMMSLibraryForm = class(TPageForm)
    mainToolBar: TmpToolBar;
    btnNewMMS: TToolButton;
    btnDelete: TToolButton;
    DataTree: TVirtualStringTree;
    ilImages: TImageList;
    btnImport: TToolButton;
    btn2: TToolButton;
    btn3: TToolButton;
    btn4: TToolButton;
    btn5: TToolButton;
    btnExport: TToolButton;
    btnRefresh: TToolButton;
    procedure FormCreate(Sender: TObject);
    procedure btnNewMMSClick(Sender: TObject);
    procedure btnDeleteClick(Sender: TObject);
    procedure btnImportClick(Sender: TObject);
    procedure btnExportClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure btnRefreshClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure DataTreeGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
      Column: TColumnIndex; TextType: TVSTTextType;
      var CellText: WideString);
    procedure DataTreeInitNode(Sender: TBaseVirtualTree; ParentNode,
      Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
  
  private
    { Private declarations }
    stringlist:TStringList;
  public
    procedure  refreshtree();
  end;

  procedure GetMMSFromLibrary(dparam: TStringList; mysql_rows: PMYSQL_ROW);

type
 PMMSTreeNode=^TMMStreeNode;

//自定义的datatree的结构
 TMMStreeNode=record
   mmsid:string;
   mmstype:string;
   mmssmil:string;
   mmssize:Integer;
   mmssubject:string;
 end;

var
  MMSLibraryForm: TMMSLibraryForm;

implementation

{$R *.dfm}

procedure TMMSLibraryForm.FormCreate(Sender: TObject);
begin
  Self.Font:=Application.MainForm.Font;                                        //保持程序中字体一致
  stringlist:=TStringList.Create;                                                       //保存要显示的数据
  DataTree.NodeDataSize:=SizeOf(TMMStreeNode);                 //初始化datatree的节点大小
end;

procedure TMMSLibraryForm.FormShow(Sender: TObject);
var
  pdbinfo: PDatabaseInfo;
  column : TVirtualTreeColumn;
  Header : TStrings;
  i      : Integer;
  node   : PVirtualNode;
  data   : PINT;

  sql    : string;
  pnode1 : PMMSTreeNode;
begin
  Header:=TStringList.Create;

//添加显示的列名
  if trim(Header.Text)= then
  begin
    Header.Add(ID);
    Header.Add(Type);
    Header.Add(Smil 1.0/2.0);
    Header.Add(Size(B));
    Header.Add(Subject);
  end;

//设置列的显示

  for i:=0 to Header.Count-1 do
  begin
    column:= DataTree.Header.Columns.Add;
    column.Text:= Header[I];
    column.Width:=dataTree.ClientWidth div 6;
    if i=4 then
       column.Width:= dataTree.ClientWidth div 3-10;
  end;

//    连接,获取指定的数据库(是不是忒简单\

pdbinfo:=currentdatabase.databases.GetByIndex(0);

    Refreshtree;

end;

procedure  TMMSLibraryForm.refreshtree();
var

Tags:

相关文章

    文章评论

    最 近 更 新
    热 点 排 行
    Js与CSS工具
    代码转换工具
    
    <