• <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++ 基礎(chǔ)} {C++ 高級(jí)} {C#界面,C++核心算法} {設(shè)計(jì)模式} {C#基礎(chǔ)}

            在Form中構(gòu)建給定目錄的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 夢(mèng)在天涯 閱讀(521) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C#/.NET

            公告

            EMail:itech001#126.com

            導(dǎo)航

            統(tǒng)計(jì)

            • 隨筆 - 461
            • 文章 - 4
            • 評(píng)論 - 746
            • 引用 - 0

            常用鏈接

            隨筆分類

            隨筆檔案

            收藏夾

            Blogs

            c#(csharp)

            C++(cpp)

            Enlish

            Forums(bbs)

            My self

            Often go

            Useful Webs

            Xml/Uml/html

            搜索

            •  

            積分與排名

            • 積分 - 1811117
            • 排名 - 5

            最新評(píng)論

            閱讀排行榜

            久久青青草原精品国产软件| 国内精品伊人久久久久妇| 久久夜色tv网站| 狠狠人妻久久久久久综合| 精品人妻伦九区久久AAA片69| 久久精品国产亚洲av麻豆色欲| 久久香蕉一级毛片| 日韩人妻无码精品久久免费一 | 色播久久人人爽人人爽人人片AV| 亚洲愉拍99热成人精品热久久| 97精品国产97久久久久久免费| 久久99精品国产麻豆宅宅| 狠狠综合久久综合中文88 | 久久亚洲视频| 久久国产精品国产自线拍免费| 伊人久久大香线蕉av不卡| 久久国产香蕉视频| 久久香蕉综合色一综合色88| 亚洲精品白浆高清久久久久久| 久久国产精品国语对白| 精品久久久久久亚洲| 少妇久久久久久被弄高潮| 国产精品久久久久久久app| 国产亚州精品女人久久久久久 | 色欲综合久久中文字幕网| 亚洲伊人久久综合中文成人网| 91精品无码久久久久久五月天| 久久久久成人精品无码中文字幕| 国内精品伊人久久久久妇| 日本久久久久久久久久| 99久久综合狠狠综合久久| 欧美一区二区精品久久| 国产成人久久激情91| 久久亚洲精品中文字幕| 人妻精品久久久久中文字幕69 | 国产成人无码精品久久久免费| 丁香五月网久久综合| 亚洲精品国产成人99久久| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 精品国际久久久久999波多野| 中文国产成人精品久久不卡 |