treeview如下:asdf
eee
1
2
3
aaaaaaa
bbbbbbbb
cccccccc如何让eee这个node依次向下移动位置(包含eee底下的子目录)?
eee
1
2
3
aaaaaaa
bbbbbbbb
cccccccc如何让eee这个node依次向下移动位置(包含eee底下的子目录)?
解决方案 »
- 存储过程快还是直接写SQL快
- 请教一个delphi开发socket三层的问题
- 请问delphix下双缓冲是自动开启的吗?
- 急~~~~~~~~!关于delphi调用Lindo的线性规划程序.请大家指点,谢谢!!(在线等待)
- 关于sql的简单问题!
- 领导指示:作个考勤软件。问:怎么防止作弊。
- 图存储问题?
- Network Management Functions中哪个函数负责创建网络连接?
- 请问哪位知道如何设置表格中一个单元格的字体属性、背景颜色?
- 怎么把整型变量转换成十六进制?急等至15:00!
- playicq.com被美国在线起诉,请求援助
- 关于利用socket通讯多线程的问题,急急!!!!!!
var tmp1nd,tmp2nd:TTreeNode;
begin
tmp1nd.MoveTo(tmp2nd,TNodeAttachMode);
end;type TNodeAttachMode = (naAdd, naAddFirst, naAddChild, naAddChildFirst, naInsert);DescriptionThe TNodeAttachMode type specifies the way a new or relocated tree node will be related to some other node.Value MeaningnaAdd The new or relocated node becomes the last sibling of the other node.
naAddFirst The new or relocated node becomes the first sibling of the other node.
naInsert The new or relocated node becomes the sibling immediately before the other node.
naAddChild The new or relocated node becomes the last child of the other node.
naAddChildFirst The new or relocated node becomes the first child of the other node.
具体你自己定义一下吧
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;type
Trysele = class(TForm)
GroupBox1: TGroupBox;
TreeView1: TTreeView;
procedure FormCreate(Sender: TObject);
procedure TreeView1Changing(Sender: TObject; Node: TTreeNode;
var AllowChange: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;var
rysele: Trysele;implementation uses condata;
{$R *.dfm}procedure Trysele.FormCreate(Sender: TObject);
var
tnd,tnd1,tnd2,tnd3:TTreeNode;
begin
dmd.cx3.Close;
dmd.cx3.SQL.Clear;
dmd.cx3.SQL.Add('select 部门 from rybm');
dmd.cx3.Open;
while not dmd.cx3.eof do
begin
tnd:=treeview1.Items.Add(nil,(dmd.cx3.FieldByName('部门').Asstring));
dmd.cx2.Close;
dmd.cx2.SQL.Clear;
dmd.cx2.SQL.Add('select 部门,组名 from rybmzu where 部门='''+dmd.cx3.fieldbyname('部门').AsString+'''');
dmd.cx2.Open;
dmd.cx2.First;
while not dmd.cx2.Eof do
begin
tnd1:=treeview1.Items.AddChild(tnd,(dmd.cx2.fieldbyname('组名').AsString));
dmd.cx4.Close;
dmd.cx4.SQL.clear;
dmd.cx4.SQL.add('select 工号,姓名 from ry where (组名='''+dmd.cx2.fieldbyname('组名').asstring+''') and (部门='''+dmd.cx2.fieldbyname('部门').asstring+''')');
dmd.cx4.Open; while not dmd.cx4.eof do begin tnd2:=treeview1.Items.addchild(tnd1,((dmd.cx4.fieldbyname('工号').asstring)+'-'+(dmd.cx4.fieldbyname('姓名').asstring))); dmd.cx4.Next
end; dmd.cx4.First;
dmd.cx2.Next;
end;
dmd.cx2.First;
dmd.cx3.next;
end;
end;procedure Trysele.TreeView1Changing(Sender: TObject; Node: TTreeNode;
var AllowChange: Boolean);
var
str:string;
i:integer;
a:integer;
j:integer;
begin
str:=node.text;
for i:=1 to length(str) do
begin
a:=pos('-',str);
if a>0 then
begin
rygh:=copy(str,1,a-1);
dmd.cx4.Close;
dmd.cx4.SQL.clear;
dmd.cx4.SQL.add('select 工号,姓名,部门,组名 from ry where 工号='''+rygh+'''');
dmd.cx4.Open;
if dmd.cx4.RecordCount>0 then
begin
rygh:=dmd.cx4.fieldbyname('工号').asstring;
ryxm:=dmd.cx4.fieldbyname('姓名').asstring;
rybm:=dmd.cx4.fieldbyname('部门').asstring;
ryzm:=dmd.cx4.fieldbyname('组名').AsString;
end;
end; end;
end;dmd.cx2和dmd.cx4你可以用两个addoquery来代替