如下dbtreeview控件在编辑,删除,增加,拖拽后如何保存到数剧库?(100分)

  • 主题发起人 主题发起人 qhx
  • 开始时间 开始时间
Q

qhx

Unregistered / Unconfirmed
GUEST, unregistred user!
unit DBTrees;

interface

uses ComCtrls, DB;

type

TTreeNodeInfo=record
Id:String;
ParentId:String;
end;

TDBTreeView=class(TTreeView)
private
fTable:TDataSet;
fId,fParentId,fName:string;
function AddItem:TTreeNode;
function FindItem(Id:string):TTreeNode;
public
function GetId:string;
procedure BuildTree;
procedure ClearTree;
published
property FieldId:string Read fId Write fId;
property FieldParentId:string Read fParentId Write fParentId;
property FieldName:string Read fName Write fName;
property DataSource:TDataSet Read fTable Write fTable;
property ActiveId:string Read GetId;
end;

procedure Register;

implementation

function TDBTreeView.FindItem(Id:string):TTreeNode;
var i:integer;
NodeInfo:^TTreeNodeInfo;
begin
Result:=nil;
For i:=0 to Items.Count-1 do
begin
NodeInfo:=Items.Data;
If NodeInfo^.Id=Id then
begin
Result:=Items;
Exit;
end;
end;
end;

function TDBTreeView.GetId:string;
var NodeInfo:^TTreeNodeInfo;
begin
If Selected=nil then Result:=''
else
begin
NodeInfo:=Selected.Data;
Result:=NodeInfo^.Id;
end;
end;

function TDBTreeView.AddItem:TTreeNode;
var NodeInfo:^TTreeNodeInfo;
BMark:TBookMark;
ObjParent:TTreeNode;
Name,CurId:string;
begin
ObjParent:=FindItem(fTable.FieldByName(fId).AsString);
If ObjParent<>nil then
{钺?牝 箧?漕徉怆屙 ?溴疱忸}
begin
Result:=ObjParent;
Exit;
end
else
{漕徉怆
 
我以前用过的思路是先更新库,然后更新树。
 
我需要先更新树,然后更新库。
 
dbtreeview控件在编辑,删除,增加,拖拽后如何保存到数剧库的问题解决了,
怎样才能产生维一的 ID号?(数剧库有3个field,id,parent,name,id不能相同)
 
把ID设成自增类型,不行吗?
 
好象是设为autoinc吧?
dbtreeview控件在编辑,删除,增加,拖拽后如何保存到数剧库?
 
后退
顶部