/// <summary>
/// 设置查找的节点为选定节点
/// 涂聚文
/// 2013-07-15
/// </summary>
/// <param name="trvToSrch"></param>
/// <param name="strToSrch"></param>
/// <returns></returns>
public TreeNode srchTxtInSelectTreeView(TreeView trvToSrch, String strToSrch)
{
// check if the treeView is not NULL
if (trvToSrch == null)
return null; // loop through the nodes in the treeview's root nodes
for (int i = 0; i < trvToSrch.Nodes.Count; i++)
{
TreeNode trvNode = srchTxtInSelectTreeViewNode(trvToSrch.Nodes[i], strToSrch);
if (trvNode != null)
return trvNode;
}
return null;
}
/// <summary>
/// 查找节点
/// </summary>
/// <param name="trvNode"></param>
/// <param name="strToSrch"></param>
/// <returns></returns>
public TreeNode srchTxtInSelectTreeViewNode(TreeNode trvNode, String strToSrch)
{
// check if the treeView is not NULL
if (trvNode == null)
return null; if (trvNode.Text == strToSrch)
return trvNode; // loop through the nodes in the treeview's sub nodes
for (int i = 0; i < trvNode.Nodes.Count; i++)
{
// recursive call to itself to check lower level nodes
TreeNode retTrvNode = srchTxtInSelectTreeViewNode(trvNode.Nodes[i], strToSrch);
if (retTrvNode != null)
return retTrvNode;
}
return null;
}
                //TreeView初始化设置默认选择节点
treeView1.SelectedNode = srchTxtInSelectTreeView(treeView1, "深圳");

Csharp: TreeView 初始化设置默认选择节点的更多相关文章

  1. Jquery-下拉列表设置默认选择

    $('#select option:eq(2)').attr('selected','selected');

  2. ngular ionic select ng-options 默认选择第一个值的写法

    1. html <select ng-model="selectOrderState" style="border:none;left:0" ng-opt ...

  3. php一些单选、复选框的默认选择方法(示例)

    转载 http://www.php.cn/php-weizijiaocheng-360029.html 一. radio和checkbox及php select默认选择的实现代码 1.radio单选框 ...

  4. 官方yum源安装选择所需版本mysql数据库并初始化(yum默认安装的是最新版MySQL8.+)

    在官网是找不到5.x系列的域名源的,系统默认是安装的oracle数据库,在安装前需要删除默认的 以下教程来源于官网说明 先去官网下载yum源,地址 https://dev.mysql.com/down ...

  5. 【转载】win10解决设置默认打开方式不生效问题(双击每次都要选择默认打开程序)

    win10解决设置默认打开方式不生效问题(双击每次都要选择默认打开程序) 以下文章 部分选自 https://blog.csdn.net/shan165310175/article/details/8 ...

  6. Confluence 6 配置推荐更新邮件通知默认的初始化设置

    Confluence 为订阅者发送常规邮件报告,这个邮件报告中包含有用户具有查看权限的空间的最新的内容.这个被称为 推荐更新(Recommended Updates)通知. 如果你具有 Conflue ...

  7. c#为字段设置默认值,以及构造函数初始化List对象。

    1.为字段设置默认值 /// <summary> /// 默认值 /// </summary> ; ; /// <summary> /// 页的大小 /// < ...

  8. 取消IDEA默认打开最近的项目(设置打开选择创建页面)

    Ctrl + Shift + s 打开设置界面 选择Appearance&Behavior 找到System Settings 将Reopen last project on startup ...

  9. BW标准数据源初始化设置

    在安装了一干补丁和做好了BW与R3的链接之后(此处有BISIS操心,具体事宜不详),我们就可以登录到R3系统看个究竟了. 磨刀不误砍柴工,先检查一下两边系统的补丁: R3端如下, ,貌似我们是19,通 ...

随机推荐

  1. 1. UML统一建模语言

    (1)UML概述: 建模: 对现实系统进行适当的过滤, 用适当的表现规则描述出简洁的模型. 建模是一种深入解决问题的方法. UML: UML(United Modeling Language, 统一建 ...

  2. Ubuntu系统使用apache部署多个django项目(python4.3)

    /etc/apache2/sites-available/pyweb.conf <VirtualHost *:> ServerName 192.168.1.46 DocumentRoot ...

  3. 航天独角兽Spacex

    2018年2月7日下午3时45分,猎鹰重型火箭在位于卡纳维拉尔角的肯尼迪航天中心LC-39A平台顺利升空.火箭直升云霄,按照既定轨道持续升空,位于美国弗罗里达州卡纳维拉尔角的航天发射中心硝烟四起,非常 ...

  4. [USACO10MAR]伟大的奶牛聚集 BZOJ 1827 树形dp+dfs

    题目描述 Bessie is planning the annual Great Cow Gathering for cows all across the country and, of cours ...

  5. 洛谷 P1372 又是毕业季I

    可能所有的数论题都是这样玄学.... 题目链接:https://www.luogu.org/problemnew/show/P1372 这道题通过暴力的枚举可以发现是不可做的(当然我也不会做) 然后就 ...

  6. angularJs表格效果

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...

  7. Jmeter函数作用域实时取值覆盖[针对HTTP Request等控制器]

    jmeter的属性和变量可以简单理解为编程里面的全局变量和局部变量.属性是全局可见,可以跨线程组传递调用,而变量基本上只能存在于一个线程组中(在测试计划定义的变量也是可以跨线程组传递的).同线程组内的 ...

  8. Android SharedPreferences(数据存储,需掌握)

    1.SharePrefences类介绍 SharedPreferences 类提供了一个通用框架,以便您能够保存和检索原始数据类型的永久性键值对. 您可以使用 SharedPreferences 来保 ...

  9. HDU 6189 Law of Commutation(规律)

    题意: 给定n,a,求区间 [ 1 , 1<<n ] 的数b 满足 的个数 分析:打出暴力程序可以发现当a为奇数的时候结果为一: 当a为偶时 , a^b=2^(k+b)mod 2^n ; ...

  10. Highcharts的一些属性

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...