我用的ini文件如下内容:
[192.168.0.105]
DataGroupIP=236.168.57.5
CommandGroupIP=236.168.57.5
DataGroupPort=5609
CommandGroupPort=5610
SubnetMask=255.255.255.0
Gateway=10.5.1.254
DeviceType=1
LastConnectPlayer=2
LastConnectChannel=1
Description=wwww
Cannel1Description=AAAA
Cannel2Description=BBBB
Cannel3Description=CCCC
Cannel4Description=DDDD
UseChannel1=1
UseChannel2=1
UseChannel3=1
UseChannel4=1
Cannel1Controller=PELCO-D1
Cannel2Controller=PELCO-D1
Cannel3Controller=PELCO-D1
Cannel4Controller=PELCO-D1
我要做的是软件运行将IP地址([192.168.0.105])下的极端内容显示在TreeView控件中(显示美容有:Description 显示为父节点;Cannel1Description、Cannel2Description、Cannel3Description、Cannel4Description显示为子节点),问题是我在TreeView控件中双击子节点的事件中利用什么信息取出ini文件里该段内容的其它信息,并加以利用。(如取出DataGroupIP、DataGroupPort等信息)
[192.168.0.105]
DataGroupIP=236.168.57.5
CommandGroupIP=236.168.57.5
DataGroupPort=5609
CommandGroupPort=5610
SubnetMask=255.255.255.0
Gateway=10.5.1.254
DeviceType=1
LastConnectPlayer=2
LastConnectChannel=1
Description=wwww
Cannel1Description=AAAA
Cannel2Description=BBBB
Cannel3Description=CCCC
Cannel4Description=DDDD
UseChannel1=1
UseChannel2=1
UseChannel3=1
UseChannel4=1
Cannel1Controller=PELCO-D1
Cannel2Controller=PELCO-D1
Cannel3Controller=PELCO-D1
Cannel4Controller=PELCO-D1
我要做的是软件运行将IP地址([192.168.0.105])下的极端内容显示在TreeView控件中(显示美容有:Description 显示为父节点;Cannel1Description、Cannel2Description、Cannel3Description、Cannel4Description显示为子节点),问题是我在TreeView控件中双击子节点的事件中利用什么信息取出ini文件里该段内容的其它信息,并加以利用。(如取出DataGroupIP、DataGroupPort等信息)
DataGroupIP As String
DataGroupPort As String
'………
End Type
public SUB AddNode()
Dim MainKey As String
Dim tepMyIP As MyIP
Dim tNode As Node
tepMyIP.DataGroupIP=236.168.57.5
tepMyIP.DataGroupPort = 5609
'……
Set tNode = TreeView1.Nodes.Add(, , , "192.168.0.105")
tNode.Tag = tepMyIP
end subPrivate Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Dim tMyIp As MyIP
tMyIp = Node.Tag
MsgBox tMyIp.DataGroupIP & "_" & tMyIp.DataGroupPort
End Sub
如下:
[192.168.0.105]
DataGroupIP=236.168.57.5
CommandGroupIP=236.168.57.5
DataGroupPort=5609
CommandGroupPort=5610
SubnetMask=255.255.255.0
Gateway=10.5.1.254
DeviceType=1
LastConnectPlayer=2
LastConnectChannel=1
Description=wwww
Cannel1Description=AAAA
Cannel2Description=BBBB
Cannel3Description=CCCC
Cannel4Description=DDDD
UseChannel1=1
UseChannel2=1
UseChannel3=1
UseChannel4=1
Cannel1Controller=PELCO-D1
Cannel2Controller=PELCO-D1
Cannel3Controller=PELCO-D1
Cannel4Controller=PELCO-D1[192.168.0.101]
DataGroupIP=236.168.57.1
CommandGroupIP=236.168.57.1
DataGroupPort=5601
CommandGroupPort=5602
SubnetMask=255.255.255.0
Gateway=10.5.1.254
DeviceType=1
LastConnectPlayer=
LastConnectChannel=
Description=wewe
Cannel1Description=asd
Cannel2Description=SDas
Cannel3Description=asd
Cannel4Description=
UseChannel1=1
UseChannel2=1
UseChannel3=1
UseChannel4=1
Cannel1Controller=PELCO-D1
Cannel2Controller=PELCO-D1
Cannel3Controller=PELCO-D1
Cannel4Controller=PELCO-D1
Set tNode = TreeView1.Nodes.Add(, ,"MainIP" & i , "Description") '加父
Set tNode = TreeView1.Nodes.Add("MainIP",4 , "Cannel1Description" & i, "AAAA") '加子Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Dim tMyIp As MyIP
tMyIp = Node.Tag
if instr(1,Node.Key ,MainIP)<>"" then
tMyIp = Node.Tag '点了一个父结点
else
tMyIp = Node.Parent.Tag 点了一个子结点
end if
MsgBox tMyIp.DataGroupIP & "_" & tMyIp.DataGroupPort
End Sub
MainIP as string '在自定义结构中加一个主IP ,存放你想知道的东西嘛
'这个自义结构你可以随便添加自己的项
DataGroupIP As String
DataGroupPort As String
'………
End TypePrivate Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Dim tMyIp As MyIP
tMyIp = Node.Tag
if instr(1,Node.Key ,MainIP)<>"" then
tMyIp = Node.Tag '点了一个父结点
else
tMyIp = Node.Parent.Tag 点了一个子结点
end if
MsgBox tMyIp.MainIP '这不就可以取192.168.0.105 或 192.168.0.101了吗?
End Sub你是说你怎么从ini中读取 [192.168.0.105] 这个吗?
………
………
………
[192.168.0.101]有很多组这个是吧?192.168.0.105 这些主键除了保存在INI中,还可以从哪里读取吗?
这个小工程你下载看一下咯,我不知道可不可以满足你最低的要求!
E-MAIL或者QQ号阿,有问题我再请教。我的是[email protected] 87950342