如何在树形视图中显示节点详细信息 [英] how to show the node details in a treeview

查看:76
本文介绍了如何在树形视图中显示节点详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个树视图,其中包含以下数据,例如ex

-Asp.net
-控件
-文本框
+验证者

因此,当用户单击文本框节点时,我必须在标签中显示文本框的完整详细信息,并且该标签应仅位于文本框下方.


在此先感谢

Hi

I have a treeview with following data for ex

-Asp.net
-Controls
-Textbox
+validators

so when user clicks on the textbox node i have to show in a label the complete details of the textbox and that label should come under the textbox only.


thanks in advance

推荐答案

您好

您好,请检查此代码一次以显示具有相应控件的属性

Hi

Hi Check this code once for displaying properties with respective control

<asp:TreeView ID="TreeView1" runat="server"
           onselectednodechanged="TreeView1_SelectedNodeChanged">
       <Nodes>
         <asp:TreeNode Text="TextBox"  >

         </asp:TreeNode>
         <asp:TreeNode Text="DropdownList"></asp:TreeNode>
         <asp:TreeNode Text="Button"></asp:TreeNode>
       </Nodes>
       </asp:TreeView>



在文件后面的代码中,您需要编写以下代码



In code behind file you need to write below code

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
  {
      showControlDetails.Visible = true;
      TreeView rootview = (TreeView)sender;
      Control txtchck =null;

      switch (rootview.SelectedNode.Text)
      {
          case ("TextBox"):
              txtchck = new TextBox();
              break;
          case ("DropdownList"):
              txtchck = new DropDownList();
              break;
          case ("Button"):
              txtchck = new Button();
              break;

      }
      if (txtchck != null)
      {
          Type controlType = txtchck.GetType();

          PropertyInfo[] properties = controlType.GetProperties();

          foreach (PropertyInfo controlProperty in properties)
          {
              TreeNode tnd = new TreeNode();
              tnd.Text = controlProperty.Name;
              rootview.SelectedNode.ChildNodes.Add(tnd);

          }
      }
  }



这次只是为了添加子节点

我将对其进行修改并在此处发布以显示为工具提示

并且您应该导入名称空间 System.Reflection;
在这里,我只为文本框做过操作,您可以对其进行修改以满足您的要求
我希望您知道如何将节点添加到treenode

最好的



Here this time it is just for adding sub nodes

I''ll modify it and post here to show as tooltip

And you should import namespaces System.Reflection;
Here i did only for textbox you can modify it to fulfill your requirement
and i hope you know how to add nodes to treenode

All the Best




这是更新的解决方案,用于在客户端单击时显示弹出窗口

Hi,

This is Updated Solution for displaying popup on client click

<asp:treeview id="TreeView1" runat="server" xmlns:asp="#unknown">
      <nodes>
        <asp:treenode text="TextBox">

        </asp:treenode>
        <asp:treenode text="DropdownList"></asp:treenode>
        <asp:treenode text="Button"></asp:treenode>
      </nodes>
      </asp:treeview>


<div id="showControlDetails1" style="   background-color:#136012;   position:fixed;left:500px;top:600px; border-color:Red;">
     dsfsdfsdfsdf
    </div>



之后,您需要添加javascript文件



After that you need to add javascript file


(文档).ready(函数(){ jQuery.fn.elementlocation = 函数(){ var curleft = 0 ; var curtop = 0 ; var obj = { curleft + = obj.attr(' offsetLeft'); curtop + = obj.attr(' offsetTop'); obj = obj.offsetParent(); } 同时(obj.attr(' tagName')!= ' BODY'); 返回({x:curleft,y:curtop}); };
(document).ready(function () { jQuery.fn.elementlocation = function () { var curleft = 0; var curtop = 0; var obj = this; do { curleft += obj.attr('offsetLeft'); curtop += obj.attr('offsetTop'); obj = obj.offsetParent(); } while (obj.attr('tagName') != 'BODY'); return ({ x: curleft, y: curtop }); };


这篇关于如何在树形视图中显示节点详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆