找回密码
 加入
搜索
查看: 1449|回复: 2

如何把INI文件的内容显示到TreeView中

[复制链接]
发表于 2009-3-10 01:48:06 | 显示全部楼层 |阅读模式
现有INI文件内容如下
[1]
ParentName=股票经济
[1-1]
ChildName=大智慧
[1-2]
ChildName=民生证券
[2]
ParentName=聊天通讯
[2-1]
ChildName=飞信2008
如何读取上面INI文件中的内容到TreeView中,如下图显示:


[ 本帖最后由 netbadbug 于 2009-3-11 12:24 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-3-10 18:43:54 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
Local $I, $J, $_Tree_Item[11][11], $_INI_File = @ScriptDir & "\1.ini"

$Form1 = GUICreate("Form1", 196, 400, 192, 124)
$TreeView = GUICtrlCreateTreeView(16, 16, 137, 361)

For $I = 1 To 9

        $IniSection = IniRead($_INI_File, "Main", $I, "None")
        If $IniSection = "None" Then ExitLoop
        
        $_Tree_Item[$I][0] = GUICtrlCreateTreeViewItem($IniSection, $TreeView)

        $IniKey = IniReadSection($_INI_File, $I)
        If @error Then ExitLoop

        For $J = 1 To $IniKey[0][0]
                GUICtrlCreateTreeViewItem($IniKey[$J][1], $_Tree_Item[$I][0])
        Next
        
        GUICtrlSetState($_Tree_Item[$I][0], BitOR($GUI_EXPAND, $GUI_DEFBUTTON))

Next

GUISetState(@SW_SHOW)

While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd


INI文件名:1.ini, 内容:
[Main]
1=股票经济
2=聊天通讯

[1]
1=大智慧
2=民生证券

[2]
1=飞信2008

[ 本帖最后由 漠北雪~狼 于 2009-3-10 18:48 编辑 ]
发表于 2009-3-10 19:24:32 | 显示全部楼层

写的好

是这样的!!!!!!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 01:56 , Processed in 0.076714 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表