zoukankan      html  css  js  c++  java
  • 带线的无限级下拉树列表

    好多年没写文章了
    这里就分享点自己原创的一点破代码,效果如图下:

    本人的提供的代码如下:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI.WebControls;

    namespace Interface.Common
    {
        
    public interface IDropDownTree : IDisposable
        
    {
            
    /// <summary>
            
    /// 返回Dictionary里分别对应ID,文本,如果没有子节点返回null
            
    /// </summary>
            
    /// <param name="parentID">父节点ID</param>
            
    /// <returns></returns>

            Dictionary<stringstring> GetChildCategory(string parentID);
            
    /// <summary>
            
    /// 代码里写return new Interface.Common.DropDownTree(this);
            
    /// </summary>

            DropDownTree DropDownTree
            
    {
                
    get;
            }

        }

        
    public sealed class DropDownTree
        
    {
            IDropDownTree _DropDownTree;
            
    public DropDownTree(IDropDownTree dropDownTree)
            
    {
                _DropDownTree 
    = dropDownTree;
            }

            
    /// <summary>
            
    /// 用于树的前缀
            
    /// </summary>
            
    /// <param name="IsLast">是否是同级节点中的最后一个</param>
            
    /// <param name="HasChild">本节点是否拥有子节点</param>
            
    /// <param name="ParentString">父节点前缀符号</param>
            
    /// <returns>本节点的前缀</returns>

            private string GetPreFix(bool isLast, bool hasChild, string parentString)
            
    {
                
    string result = string.Empty;
                
    if (!string.IsNullOrEmpty(parentString))
                
    {
                    parentString 
    = parentString.Remove(parentString.Length - 1).Replace("""").Replace(""" ");
                    result 
    += parentString;
                }

                
    if (isLast)
                
    {
                    result 
    += "";
                }

                
    else
                
    {
                    result 
    += "";
                }

                
    if (hasChild)
                
    {
                    result 
    += "";
                }

                
    else
                
    {
                    result 
    += "";
                }

                
    return result;
            }

            
    绑定下拉菜单
        }

    }


    调用方法很简单:
    1.继承自IDropDownTree接口
    2.实现3个接口方法

    实现接口代码示例[Dispose方法自己实现],最主要的是自己实现获得子级的方法
     IDropDownTree 成员

    页面调用代码: 类名.DropDownTree.BindToDropDownList(下拉控件ID);

    希望对大伙有点帮助....
    版权声明:本文原创发表于 博客园,作者为 路过秋天 本文欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则视为侵权。
    个人微信公众号
    创业QQ群:617713515
    Donation(扫码支持作者):支付宝:
    Donation(扫码支持作者):微信:
  • 相关阅读:
    MAC上最好用的免费全能音乐播放器VOX 2.6.5
    Linux发行版的排行
    Linux发行版的排行
    ImageButton的背景设为透明或者半透明以及按下效果
    ImageButton的背景设为透明或者半透明以及按下效果
    软件缘-网友个人精心打造的精品软件收集
    软件缘-网友个人精心打造的精品软件收集
    滚动条
    em
    配色
  • 原文地址:https://www.cnblogs.com/cyq1162/p/1157507.html
Copyright © 2011-2022 走看看