• <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 夢在天涯 閱讀(521) 評論(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

            搜索

            •  

            積分與排名

            • 積分 - 1811124
            • 排名 - 5

            最新評論

            閱讀排行榜

            国产2021久久精品| 久久99久国产麻精品66| 久久九九免费高清视频| 久久婷婷是五月综合色狠狠| 人妻无码αv中文字幕久久琪琪布| 国产精品久久久天天影视| 午夜福利91久久福利| 久久精品无码专区免费东京热| 国产精品99久久久久久www| 国产美女亚洲精品久久久综合 | 久久精品国产亚洲5555| 亚洲AV无码久久精品狠狠爱浪潮| 中文字幕成人精品久久不卡| 亚洲中文久久精品无码ww16| 国产一区二区精品久久岳| 久久精品国产亚洲AV无码偷窥| 人妻少妇精品久久| 日本免费久久久久久久网站 | 97久久精品人妻人人搡人人玩| 久久久久九九精品影院| 久久精品国产只有精品2020| 婷婷久久香蕉五月综合加勒比| 国产精品久久久久免费a∨| 91久久精品国产成人久久| 久久人人妻人人爽人人爽| 欧美黑人激情性久久| 色综合久久夜色精品国产| 国产亚洲美女精品久久久| 久久国产精品一区| 久久久久久无码国产精品中文字幕 | 久久夜色撩人精品国产| 久久精品国产WWW456C0M| 99久久婷婷国产一区二区| 久久精品国内一区二区三区| 亚洲一本综合久久| 日本免费久久久久久久网站| 久久久青草久久久青草| 久久99热这里只有精品国产| 久久狠狠一本精品综合网| 国产成人综合久久久久久| 久久精品国产一区二区三区不卡|