国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

[VB.NET+XML]完成簡單程序配置

2024-07-10 13:00:39
字體:
來源:轉載
供稿:網友
 

簡單的一個應用例子 ,只是簡單的操作xml文件,在實際的應用上可以先建一個配置類保存狀態。

xml文件的結構:

1 <?xml version="1.0" encoding="utf-8" ?>
2  <config>
3  <function name="a" checked="false" />
4  <function name="b" checked="false" />
5  <function name="c" checked="false" />
6  <function name="d" checked="false" />
7  </config>

具體的程序:需要一個checkedlistbox,兩個button

 1    public doc as new xmldocument
2    public rootnode as xmlelement
3    public strpathconfig as string = application.startuppath & "/config.xml"
4    public intnum as int16
5    private sub button1_click()sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click
6        writeconfig()
7    end sub
8    private sub form1_load()sub form1_load(byval sender as system.object, byval e as system.eventargs) handles mybase.load
9        '做準備工作
10        doc.load(strpathconfig)
11        rootnode = doc.documentelement
12        intnum = rootnode.childnodes.count - 1
13        '
14        loadconfig()
15    end sub
16    '添加到checkedlistbox
17    function loadconfig()function loadconfig()
18        dim i as int16
19        for i = 0 to intnum
20            checkedlistbox1.items.add(rootnode.childnodes(i).attributes(0).value, ctype(rootnode.childnodes(i).attributes(1).value, boolean))
21        next
22    end function
23    '確定,然后寫入xml
24    function writeconfig()function writeconfig()
25        dim i as int16
26        dim str as string
27        for i = 0 to intnum
28            rootnode.childnodes(i).attributes(1).value = checkedlistbox1.getitemchecked(i).tostring
29        next
30        doc.save(strpathconfig)
31    end function
32
33    private sub button2_click()sub button2_click(byval sender as system.object, byval e as system.eventargs) handles button2.click
34        '需要清除checkedlistbox內的items
35        checkedlistbox1.items.clear()
36        loadconfig()
37    end sub

end---
  • 網站運營seo文章大全
  • 提供全面的站長運營經驗及seo技術!
  • 發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 沂源县| 正安县| 巴中市| 广东省| 新和县| 洮南市| 阿勒泰市| 衡东县| 大石桥市| 濮阳县| 陆丰市| 赣榆县| 德州市| 和硕县| 松江区| 怀宁县| 宜君县| 左权县| 舞钢市| 潼关县| 额尔古纳市| 台北县| 无极县| 孙吴县| 休宁县| 张北县| 新绛县| 荔波县| 平江县| 富阳市| 寻乌县| 高阳县| 丘北县| 浦城县| 江城| 安徽省| 云浮市| 贵德县| 满洲里市| 蒙阴县| 卢龙县|