zoukankan      html  css  js  c++  java
  • 支持树型的GridView控件

     

    支持树型的GridView

    实现思路: 继承自Gridview,处理gridview的数据源,使其在帮定时,就已经按照树型菜单顺序排列好,那样只需在帮定处理其图片是javascript脚本就可以了

    源代码下载:https://files.cnblogs.com/wschacker/TreeListView.rar

    效果图:

    代码:

    Code
     public class TreeListViewRow : GridViewRow
        
    {
            
    public TreeListViewRow(int rowIndex, int dataItemIndex, DataControlRowType rowType, DataControlRowState rowState)
                : 
    base(rowIndex, dataItemIndex, rowType, rowState)
            
    {

            }

            
            
    protected override void OnPreRender(EventArgs e)
            
    {
                
    base.OnPreRender(e);
                
    if (this.RowType == DataControlRowType.DataRow)
                
    {
                    
    if (this.Parent.Parent is TreeListView)
                    
    {
                        TreeListView treeListView 
    = this.Parent.Parent as TreeListView;
                        DataRow dr 
    = ((DataTable)treeListView.DataSource).Rows[this.DataItemIndex] as DataRow;
                        
    string str = GetTreeNodeImg(dr, Convert.ToBoolean(dr["TreeListView$Row$IsLeaf"]), Convert.ToBoolean(dr["TreeListView$Row$IsBottom"]));
                        
    this.Cells[treeListView.NodeColumnIndex].Text = str + this.Cells[treeListView.NodeColumnIndex].Text;
                        
    this.ID = dr["TreeList$ViewRow$ClientID"].ToString();
                        
    if (treeListView.ExpendDepth > 0)
                        
    {
                            
    this.Style["display"= treeListView.ExpendDepth >= Convert.ToInt32(dr["TreeListView$Row$Depth"]) ? "block" : "none";
                        }

                    }

                }

                
            }


            
    获取Tree的图片

    Js代码实现折叠效果

    Code
  • 相关阅读:
    【USACO1.6.3】Prime Palindromes【数论,数学】【模拟】
    【HDU6345】子串查询【前缀和】【线段树】
    【HDU6345】子串查询【前缀和】【线段树】
    【HDU6344】调查问卷【状压】【模拟】
    【HDU6344】调查问卷【状压】【模拟】
    获取一个处理程序函数到一个特定的弹出菜单
    一个剪贴板增强工具
    将checklistbox控件与DataView绑定
    探索者命令式的三分
    ColorListBox
  • 原文地址:https://www.cnblogs.com/wschacker/p/1250446.html
Copyright © 2011-2022 走看看