• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            C++ Programmer's Cookbook

            {C++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

            在Form中構建給定目錄的Treeview

            using ?System;
            using ?System.IO;
            using ?System.Drawing;
            using ?System.Collections;
            using ?System.ComponentModel;
            using ?System.Windows.Forms;
            using ?System.Data;

            namespace ?WindowsApplication
            {
            ????
            /// ? <summary>
            ????
            /// ?Summary?description?for?Form1.
            ????
            /// ? </summary>

            ???? public ? class ?Form1?:?System.Windows.Forms.Form
            ????
            {
            ????????
            private ?System.Windows.Forms.TreeView?treeView1;
            ????????
            /// ? <summary>
            ????????
            /// ?Required?designer?variable.
            ????????
            /// ? </summary>

            ???????? private ?System.ComponentModel.Container?components? = ? null ;

            ????????
            public ?Form1()
            ????????
            {
            ????????????
            //
            ????????????
            // ?Required?for?Windows?Form?Designer?support
            ????????????
            //
            ????????????InitializeComponent();

            ????????????
            //
            ????????????
            // ?TODO:?Add?any?constructor?code?after?InitializeComponent?call
            ????????????
            //
            ????????????Text? = " my?explore " ;
            ????????}


            ????????
            /// ? <summary>
            ????????
            /// ?Clean?up?any?resources?being?used.
            ????????
            /// ? </summary>

            ???????? protected ? override ? void ?Dispose(? bool ?disposing?)
            ????????
            {
            ????????????
            if (?disposing?)
            ????????????
            {
            ????????????????
            if ?(components? != ? null )?
            ????????????????
            {
            ????????????????????components.Dispose();
            ????????????????}

            ????????????}

            ????????????
            base .Dispose(?disposing?);
            ????????}


            ????????
            Windows?Form?Designer?generated?code

            ????????
            private ? void ?Fill(TreeNode?dirNode)?
            ????????
            {

            ????????????DirectoryInfo?dir?
            = ? new ?DirectoryInfo(dirNode.FullPath);
            ????????????
            ????????????
            // ?An?exception?could?be?thrown?in?this?code?if?you?don't
            ????????????
            // ?have?sufficient?security?permissions?for?a?file?or?directory.
            ????????????
            // ?You?can?catch?and?then?ignore?this?exception.
            ???????????? foreach ?(DirectoryInfo?dirItem? in ?dir.GetDirectories())?
            ????????????
            {

            ????????????????
            // ?Add?node?for?the?directory.
            ????????????????TreeNode?newNode? = ? new ?TreeNode(dirItem.Name);
            ????????????????dirNode.Nodes.Add(newNode);
            ????????????????newNode.Nodes.Add(
            " * " );
            ????????????}

            ????????}


            ????????
            /// ? <summary>
            ????????
            /// ?The?main?entry?point?for?the?application.
            ????????
            /// ? </summary>

            ????????[STAThread]
            ????????
            static ? void ?Main()?
            ????????
            {
            ????????????Application.Run(
            new ?Form1());
            ????????}


            ????????
            private ? void ?Form1_Load( object ?sender,?System.EventArgs?e)
            ????????
            {
            ????????????
            // ?Set?the?first?node.
            ????????????TreeNode?rootNode? = ? new ?TreeNode( " C:\\ " );
            ????????????treeView1.Nodes.Add(rootNode);

            ????????????
            // ?Fill?the?first?level?and?expand?it.
            ????????????Fill(rootNode);
            ????????treeView1.Nodes[
            0 ].Expand();

            ????????}


            ????????
            private ? void ?treeView1_BeforeExpand( object ?sender,?System.Windows.Forms.TreeViewCancelEventArgs?e)
            ????????
            {
            ????????????
            // ?If?a?dummy?node?is?found,?remove?it?and?read?the?
            ????????????
            // ?real?directory?list.
            ???????????? if ?(e.Node.Nodes[ 0 ].Text? == ? " * " )?
            ????????????
            {

            ????????????????e.Node.Nodes.Clear();
            ????????????????Fill(e.Node);
            ????????????}

            ????????}

            ????}

            }

            posted on 2006-03-23 17:15 夢在天涯 閱讀(518) 評論(0)  編輯 收藏 引用 所屬分類: C#/.NET

            公告

            EMail:itech001#126.com

            導航

            統計

            • 隨筆 - 461
            • 文章 - 4
            • 評論 - 746
            • 引用 - 0

            常用鏈接

            隨筆分類

            隨筆檔案

            收藏夾

            Blogs

            c#(csharp)

            C++(cpp)

            Enlish

            Forums(bbs)

            My self

            Often go

            Useful Webs

            Xml/Uml/html

            搜索

            •  

            積分與排名

            • 積分 - 1807503
            • 排名 - 5

            最新評論

            閱讀排行榜

            国内精品人妻无码久久久影院导航| 国内精品久久久久久久久电影网| 精品久久777| 99久久精品免费观看国产| 久久久精品人妻无码专区不卡| 日本五月天婷久久网站| 久久综合狠狠色综合伊人| 日本久久中文字幕| 国产精品久久久久久久久鸭| 亚洲?V乱码久久精品蜜桃| 丁香五月网久久综合| 日本欧美国产精品第一页久久| 国产精品无码久久综合| 精品国产乱码久久久久软件| 久久精品国产亚洲沈樵| 亚洲国产另类久久久精品| 久久免费99精品国产自在现线| 人妻精品久久久久中文字幕69| 少妇被又大又粗又爽毛片久久黑人 | 久久精品国产亚洲av水果派| 久久99精品久久久久久9蜜桃| 亚洲AV无码久久精品蜜桃| 亚洲精品无码久久久| 国产香蕉97碰碰久久人人| 99精品国产在热久久无毒不卡| 久久99精品国产麻豆宅宅| 要久久爱在线免费观看| 久久久久亚洲AV成人网人人软件 | 综合久久给合久久狠狠狠97色| 久久丫精品国产亚洲av不卡| 一日本道伊人久久综合影| 女同久久| 亚洲国产香蕉人人爽成AV片久久| 99久久婷婷国产综合精品草原| 久久精品国产免费| 秋霞久久国产精品电影院| 国产精品久久一区二区三区 | 精品一区二区久久| 久久精品国产半推半就| 88久久精品无码一区二区毛片| 久久91精品国产91久久小草|