请大家帮我一下,谢谢.

tfy_002 2004-09-23 11:33:37
我想用vfp做一个犹如在windows98资源管理器的树型目录的向导,该如何实现.
...全文
62 5 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
tfy_002 2004-09-24
  • 打赏
  • 举报
回复
谢谢你们
dfwxj 2004-09-24
  • 打赏
  • 举报
回复
用ACTIVEX控件TREEVIEW
tfy_002 2004-09-24
  • 打赏
  • 举报
回复
我调试了一个怎么不可以.为什么说该句为不合方法 IF FILE("xm.dbf") 我还需要在添加其它数据表或控件吗?
xclzteb 2004-09-24
  • 打赏
  • 举报
回复
楼上的可以了。
十豆三 2004-09-24
  • 打赏
  • 举报
回复
转贴------------------------------

TreeView控件使用示例

  以下代码是本演示的全部代码,你只要把它拷贝到任一PRG文件中,执行该文件你就可以看到相应的效果。该代码段在执行后会在目录下自动生成一个Xm.dbf文件,运行后可自行删除。

CLEAR ALL
CLOSE ALL
CLEAR PROGRAM

PUBLIC TreeView
Create_Dbf()
oForm = CREATEOBJECT("TreeView")
oForm.show()
RETURN

DEFINE CLASS TreeView AS form

Height = 258
Width = 388
DoCreate = .T.
AutoCenter = .T.
Caption = "TreeView 控件示例"
MaxButton = .F.
MinButton = .F.
WindowType = 1
BackColor = RGB(128,128,255)
Name = "TreeView"
Key = 0

ADD OBJECT label1 AS label WITH ;
BackStyle = 0, ;
Caption = "", ;
Height = 102, ;
Left = 198, ;
Top = 16, ;
Width = 180, ;
Name = "Label1"

ADD OBJECT command1 AS commandbutton WITH ;
Top = 211, ;
Left = 217, ;
Height = 32, ;
Width = 149, ;
Caption = "退出演示", ;
Name = "Command1"

ADD OBJECT command2 AS commandbutton WITH ;
Top = 173, ;
Left = 217, ;
Height = 32, ;
Width = 67, ;
Caption = "添加节点", ;
Name = "Command2"

ADD OBJECT command3 AS commandbutton WITH ;
Top = 173, ;
Left = 299, ;
Height = 32, ;
Width = 67, ;
Caption = "删除节点", ;
Name = "Command3"

ADD OBJECT tree AS olecontrol WITH ;
    OLECLASS="COMCTL.TreeCtrl.1",;
    Top = 0,;
    Left = 0,;
    Width = 182,;
    Height = 258,;
    HideSelection = .F.

PROCEDURE Init
Select xm
o = This.Tree
Scan
  If AllTrim(Node) = '0_'
    o.Nodes.Add(, 1, AllTrim(Key), AllTrim(Text))
  Else
    o.Nodes.Add(AllTrim(Node), 4, AllTrim(Key), AllTrim(Text))
  EndIf
EndScan
    This.Key = o.Nodes.Count
    o.Setfocus
ENDPROC

PROCEDURE Tree.Init
    This.LabelEdit = 1
    This.LineStyle = 1
    This.Indentation = 18
ENDPROC

PROCEDURE command1.Click
CLOSE ALL
RELEASE ThisForm
ENDPROC

PROCEDURE command2.Click
o = ThisForm.Tree
IF ISNULL(o.SelectedItem)
  RETURN
ENDIF
ThisForm.Key = ThisForm.Key + 1
nKey = ALLTRIM(STR(ThisForm.Key)) + "_"
nNode = o.SelectedItem.Key
nText = "新添加节点"
o.Nodes.Add(nNode, 4, nKey, nText)
o.Setfocus
ENDPROC

PROCEDURE command3.Click
o = ThisForm.Tree
IF ISNULL(o.SelectedItem)
  RETURN
ENDIF
Ip = o.SelectedItem.Index
o.Nodes.Remove(Ip)
o.Setfocus
ENDPROC

PROCEDURE Tree.NodeClick
LPARAMETERS node
IF ISNULL(This.SelectedItem)
  RETURN
ENDIF
Ip = OCCURS("\", Node.FullPath)
ThisForm.label1.Caption = "你现在选中是: 第 " + ALLTRIM(STR(Ip + 1)) + " 层节点" + CHR(13) + CHR(13) +;
             "节点Key 值是:  " + Node.Key + CHR(13) + CHR(13) +;
             "节点Text值是:  " + Node.Text
ENDPROC

ENDDEFINE

PROCEDURE Create_Dbf

  IF FILE("xm.dbf")
    DELETE FILE xm.dbf recycle
  ENDIF
  CREATE TABLE xm(KEY c(2), Node c(2), Text c(20))
  INSERT INTO xm(Key, Node, Text) ValUes("1_", "0_", "浙江省")
  INSERT INTO xm(Key, Node, Text) ValUes("2_", "0_", "广东省")
  INSERT INTO xm(Key, Node, Text) ValUes("3_", "1_", "诸暨市")
  INSERT INTO xm(Key, Node, Text) ValUes("4_", "2_", "东莞市")
  INSERT INTO xm(Key, Node, Text) ValUes("5_", "3_", "安华镇")
  INSERT INTO xm(Key, Node, Text) ValUes("6_", "4_", "石龙镇")
  RETURN
发帖
VFP

2576

社区成员

VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
社区管理员
  • VFP社区
加入社区
帖子事件
创建了帖子
2004-09-23 11:33
社区公告
暂无公告