谁给我一个TREEVIEW祥细的例子?(0分)

  • 主题发起人 主题发起人 zgxzgx2002
  • 开始时间 开始时间
Z

zgxzgx2002

Unregistered / Unconfirmed
GUEST, unregistred user!
各位前辈:本人刚学DELPHI二个月虽看了一些不太完整的例子,但没实际掌握。
谁能给我一些较完整功能的多层TREEVIEW例子?要有创建、增加、删除等功能
最好有较祥细的说明和数据库表的设计
分全敬上,最好者另加200分
谢谢
E_mail: zgx1972@sina.com
 
请高手帮忙
 
http://delphibbs.com/delphibbs/dispq.asp?lid=680438
有源码
 
不好用,连接不上
 
我给你发过去了。
 
声明:不是好例子,只是正好做到!

unit MainU;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;

type
TForm1 = class(TForm)
TreeView1: TTreeView;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
treeview1.Items.Clear;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
Anode:Ttreenode;
Anodet:Ttreenode;
begin
Anode:=treeview1.Items.Add(nil,'SDS');
anodet:=treeview1.Items.AddChild(Anode,'财务部');
treeview1.Items.AddChild(anodet,'张');
treeview1.Items.AddChild(anodet,'栗');
treeview1.Items.AddChild(anode,'业务部');
treeview1.Items.AddChild(anode,'专卖部');
anodet:=treeview1.Items.AddChild(anode,'企划部');
treeview1.Items.AddChild(anodet,'曹');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
if treeview1.Selected=nil then exit;
treeview1.Selected.Expand(true);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
treeview1.Items.AddChild(treeview1.Selected,'X咿');
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
if treeview1.Selected=nil then exit;
treeview1.Items.Delete(treeview1.Selected);
end;

end.
 
谢谢大家.
请问sword_liu如何将EX_文件转变成EXE文件?能否将转变好的发给我?谢谢.
 
你直接改就可以了
 
sword_liu:
你好,请问如何改啊?试过多次都不行,请帮忙。
yifeibbs:
你的例子好像没连接数据库。

各位大侠谁有好例子请发给我,谢谢。

 
你在windows的档案总管中把它后面的_改成e不就可以了?
因为很多email服务器不允许发送可执行文件,所以我稍微改了一下名字啊。
 
谢谢sword_liu,你的例子不但对我学习TREEVIER有好处;对其他控件的学习也有很大帮助。
只是程序不能运行,提示有如下错误。因我刚学不久希望你能帮我看看如何修改。
[Error] TipLoader.pas(160): '=' expected but 'PROCEDURE' found
[Error] TipLoader.pas(160): Unknown directive: 'message'
[Error] TipLoader.pas(163): ';' expected but '.' found
[Error] TipLoader.pas(164): ';' expected but ')' found
[Error] TipLoader.pas(168): Undeclared identifier: 'TreeView1'
[Error] TipLoader.pas(169): Undeclared identifier: 'Items'
[Error] TipLoader.pas(171): ')' expected but identifier 'Text' found
[Error] TipLoader.pas(174): Undeclared identifier: 'Node'
[Error] TipLoader.pas(180): Identifier redeclared: 'TForm1'
[Error] TipLoader.pas(180): ';' expected but ')' found
[Error] TipLoader.pas(196): Identifier redeclared: 'TForm1'
[Error] TipLoader.pas(202): Identifier redeclared: 'TForm1'
[Error] TipLoader.pas(208): Identifier redeclared: 'TForm1'
[Error] TipLoader.pas(212): Undeclared identifier: 'Panel3'
[Error] TipLoader.pas(212): Undeclared identifier: 'Panel1'
[Error] TipLoader.pas(212): Undeclared identifier: 'X'
[Error] TipLoader.pas(216): Identifier redeclared: 'TForm1'
[Error] TipLoader.pas(218): Undeclared identifier: 'ComboBox1'
[Error] TipLoader.pas(219): Undeclared identifier: 'TreeView1'
[Error] TipLoader.pas(219): Not enough actual parameters
[Error] TipLoader.pas(223): Identifier redeclared: 'TForm1'
[Error] TipLoader.pas(227): Undeclared identifier: 'StatusBar1'
[Error] TipLoader.pas(227): Missing operator or semicolon
[Error] TipLoader.pas(227): '(' expected but ':=' found
[Error] TipLoader.pas(228): Missing operator or semicolon
[Error] TipLoader.pas(228): '(' expected but ':=' found
[Error] TipLoader.pas(230): Missing operator or semicolon
[Error] TipLoader.pas(230): '(' expected but ':=' found
[Error] TipLoader.pas(231): Statement expected, but expression of type 'String' found
[Error] TipLoader.pas(231): Missing operator or semicolon
[Error] TipLoader.pas(231): '(' expected but ':=' found
[Error] TipLoader.pas(232): Missing operator or semicolon
[Error] TipLoader.pas(232): '(' expected but ':=' found
[Error] TipLoader.pas(233): Statement expected, but expression of type 'String' found
[Error] TipLoader.pas(233): Missing operator or semicolon
[Error] TipLoader.pas(233): '(' expected but ':=' found
[Error] TipLoader.pas(234): Missing operator or semicolon
[Error] TipLoader.pas(234): '(' expected but ':=' found
[Error] TipLoader.pas(235): Statement expected, but expression of type 'String' found
[Error] TipLoader.pas(235): Missing operator or semicolon
[Error] TipLoader.pas(235): '(' expected but ':=' found
[Error] TipLoader.pas(236): Undeclared identifier: 'update'
[Error] TipLoader.pas(240): Identifier redeclared: 'TForm1'
[Error] TipLoader.pas(242): Undeclared identifier: 'NoteBook1'
[Error] TipLoader.pas(243): Undeclared identifier: 'DataBase1'
[Error] TipLoader.pas(243): Missing operator or semicolon
[Error] TipLoader.pas(244): Undeclared identifier: 'Table1'
[Error] TipLoader.pas(245): Undeclared identifier: 'Table2'
[Error] TipLoader.pas(247): Undeclared identifier: 'LoadTips'
[Error] TipLoader.pas(248): Undeclared identifier: 'DataSource1'
[Error] TipLoader.pas(248): Missing operator or semicolon
[Fatal Error] TipLoader.pas(253): Compilation terminated; too many errors
 
从这里开始去掉代码,这是我从别的地方拷过来的,不明白的话我重新发给你。
//¶¨ÒåÓû§ÏûÏ¢
const
WM_EditItem = WM_User+100;

//´°ÌåÖнÓÊÜÏûÏ¢
private
{ Private declarations }
procedure WMEditItem(var Message: TMessage); message WM_EditItem;

//×îºó......
procedure TForm1.TreeView1Edited(Sender: TObject; Node: TTreeNode;
var S: String);
var
i:Integer;
begin
with TreeView1 do
for i:=0 to Items.Count-1 do
begin
if (Items.Text=S) and (Items<>Node) then
begin
ShowMessage('The Item '+S+' Already in this Project!');
PostMessage(Form1.Handle, WM_EditItem, Integer(Node), 0);
Break;
end
end;
end;

procedure TForm1.WMEditItem(var Message: TMessage);
begin
with TTreeNode(Message.WParam) do
EditText;
end;



//把这以前的代码去掉

// ******* ·&amp;Ouml;&amp;frac12;&amp;ccedil;&amp;Iuml;&amp;szlig;&amp;Ograve;&amp;AElig;&amp;para;&amp;macr;&amp;Ecirc;&amp;micro;&amp;Iuml;&amp;Ouml;·&amp;frac12;·¨ *******
{ *******
&amp;frac12;&amp;ccedil;&amp;Atilde;&amp;aelig;&amp;Ograve;&amp;Ocirc;&amp;Ograve;&amp;raquo;&amp;cedil;&amp;ouml;Panel(Panel2&amp;pound;&amp;copy;×÷&amp;Icirc;&amp;ordf;&amp;Otilde;&amp;ucirc;&amp;cedil;&amp;ouml;&amp;frac12;&amp;ccedil;&amp;Atilde;&amp;aelig;&amp;micro;&amp;Auml;&amp;micro;×&amp;Atilde;&amp;aelig;&amp;iquest;&amp;Oslash;&amp;Ouml;&amp;AElig;&amp;Egrave;&amp;Yacute;&amp;AElig;÷&amp;pound;&amp;not;&amp;Otilde;&amp;acirc;&amp;Ntilde;ù&amp;frac12;&amp;ccedil;&amp;Atilde;&amp;aelig;&amp;frac12;&amp;laquo;&amp;sup2;&amp;raquo;&amp;raquo;á&amp;Ecirc;&amp;Uuml;·&amp;Ouml;±&amp;aelig;
&amp;Acirc;&amp;Ecirc;&amp;acute;ó&amp;ETH;&amp;iexcl;&amp;para;&amp;oslash;&amp;Ocirc;ì&amp;sup3;&amp;Eacute;&amp;raquo;ì&amp;Acirc;&amp;Ograve;&amp;pound;&amp;not;&amp;Ocirc;&amp;Ugrave;&amp;Ograve;&amp;Ocirc;Panel3&amp;ordm;&amp;Iacute;Panel4&amp;Aacute;&amp;frac12;&amp;cedil;&amp;ouml;Panel·&amp;Ouml;&amp;frac34;&amp;Oacute;×ó&amp;Oacute;&amp;Ograve;&amp;pound;&amp;not;&amp;Ouml;&amp;ETH;&amp;frac14;&amp;auml;&amp;Ocirc;&amp;Ugrave;·&amp;Aring;&amp;Ograve;&amp;raquo;&amp;cedil;&amp;ouml;Panel1
&amp;Icirc;&amp;ordf;·&amp;Ouml;&amp;frac12;&amp;ccedil;&amp;Iuml;&amp;szlig;&amp;iexcl;&amp;pound;
******* }
 
我重新发了。
 
我有一个例子,但是数据库是用的oracle,连接使用的是ODAC,想要的话给我发信BXQXB@SINA.COM
 
谢谢sword_liu,你的例子对我学习TREEVIERt很有好处;我另外给你加分。
但你的例子好像只有二层,不能任意层添加子结点。


各位大侠谁有TREEVIEW的好例子(能任意添加子层,有增加删除功能的)请发给我,谢谢。另加分

 
adoquery1->select * from 分类
adoquery1->select * from 商品 where 分类=分类->名称
源代码如下:
var treenode1,treenode2:TTreeNode;
Begin
adoquery1.First;
treenode1:=add(nil,'---请先择商品分类---');
//增加根接点;
While not adoquery1.Eof do
begin
TreeNode1:=Add(nil, adoquery1['s_class']);
TreeNode1.ImageIndex:=0;
TreeNode1.SelectedIndex:=0;
adoquery2.Active:=false;
adoquery2.Parameters[0].Value:=adoquery1['s_class'];
adoquery2.Active:=true;
//增加子节点
While not adoquery2.Eof do
begin
TreeNode2:=AddChild(TreeNode1,adoquery2['s_pro_name']);
TreeNode2.ImageIndex:=1;
TreeNode2.SelectedIndex:=2;
adoquery2.Next;

end;
adoquery1.Next;
end;
treeview1.Refresh;
end;


end;

删除操作为; treeview1.selected.delete;
添加为: treeview1.selected.addchild() //查查函数库

 
给你发过去了,我用的是DELPHI7+ORACLE9I
 

Similar threads

D
回复
0
查看
802
DelphiTeacher的专栏
D
D
回复
0
查看
747
DelphiTeacher的专栏
D
D
回复
0
查看
696
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部