treeView和递归的简单运用
来源:互联网 发布:雷电osoppo系统优化 编辑:程序博客网 时间:2024/04/30 10:01
QQ:675556820
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace treeview{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { string path = @"F:\demo"; LoadDirectoryAndFile(treeView1.Nodes,path); } private void LoadDirectoryAndFile(TreeNodeCollection tnc, string path) { //获取文件夹 string[] dirs = Directory.GetDirectories(path); for (int i = 0; i < dirs.Length; i++) { TreeNode tn = tnc.Add(Path.GetFileName(dirs[i])); LoadDirectoryAndFile(tn.Nodes, dirs[i]);//递归遍历 } //获取文件 string[] files = Directory.GetFiles(path,"*.txt"); //只加载.txt for (int i = 0; i < files.Length; i++) { TreeNode tn1 = tnc.Add(Path.GetFileName(files[i])); ////Tag:可以存任何东西,在这里存的是文本文件的路径,因为文件夹不需要显示在文本框中 tn1.Tag = files[i]; } } private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (treeView1.SelectedNode.Tag != null) { textBox1.Text = File.ReadAllText(treeView1.SelectedNode.Tag.ToString(), Encoding.Default); } } }}
0 0
- treeView和递归的简单运用
- 【递归】递归的运用
- Treeview的递归绑定
- Treeview的递归绑定
- Treeview的递归绑定
- TreeView的递归分析
- 递归函数的执行机制和运用
- listview和treeview的简单用法
- listview和treeview的简单用法
- TreeView和Menu关于数据库递归的用法
- 罗马数字转换成阿拉伯数字以及递归的简单运用
- 递归的运用
- 递归的运用
- treeview的数据绑定递归
- Treeview的一个递归算法
- TreeView的简单使用
- TreeView的简单操作
- 简单的TreeView
- matplotlib 安装方法
- poj1598
- 新手入门如何选择linux版本
- 人生观
- memset用法详解
- treeView和递归的简单运用
- 防止恶意登录机制
- Android中将布局文件/View添加至窗口过程分析 ---- 从setContentView()谈起
- 一个有趣的问题: 什么情况下x, &x, *x, **x, ***x, ****x, *****x的值完全相等?
- 方差与协方差矩阵
- JavaScript中的原型和继承
- Android之SurfaceView
- 【android+opencv人脸检测】
- 异常Exception in thread "AWT-EventQueue-XX" java.lang.StackOverflowError