Summarize the experience of using MS's Tree control, everyone to share, of course, there are no more good insights that have other netizens, and others, please let me know!
I believe that as long as you read this small dish carefully, refer to the routines provided, you must master the basic usage of Tree!
1. If you want to do something, you must first sharpen them. First ensure your components, this package is very convenient, just find and use in the toolbar of VS.NET, just run: http: //218.56.11.178: 8018 / filedown.aspx? FID = 4 You can pay attention to whether there is a new version of the official station: http://msdn.microsoft.com/downloads/samples/internet/default.asp? URL = / Downloads / Samples / Internet / ASP_DOT_NET_SERVERCONTROLS / WebControls / Default.asp
2. Several properties and methods for common use ~ INDEX get the position of the tree node in the tree node collection. ~ Nodes Get the tree node collection assigned to the tree view control. ~ Parent gets or sets the parent container for the control. ~ SelectedNode Gets or sets the tree node currently selected in the tree view control. ~ ExpandALL Expands all tree nodes. ~ Checked gets or sets a value to indicate if the tree node is selected. ~ Text Gets or sets the text displayed in the tree node tag. ~ Expand Expand the tree node. ~ CLEAR Clear Tree ~ Remove removes the current tree node from the tree view control. The above is summarized by other netizens, add: ~ Height control to the width of the width control ~ Backcolor background color ~ BorderColor Border Color ~ BorderWidth Border Width ~ CSSClass Apply CSS class name ~ ExpandedImageURL Display Node icon ~ imageURL is not selected or expanded is a displayed node icon ~ SelectedImageURL Select the node icon displayed in the state ~ Indent indentation distance, only when ShowLines is set to true. ~ Showlines Displays the hierarchical cable ~ showPlus display /- symbol button ~ ShowTooltip Display Tool Tips on the Parent Node ( /- N) Expand / Off). ~ When using the keyboard shortcut ~ AutoSelect is TRUE, when moving the node with the keyboard, automatically select the new node ~ AutoPostBack When changing the state, the Enable status of the Enabled Control control is automatically saved. With the number of layers of the expanded node ~ SelectExpands when the selectexpands is selected, whether the node is automatically expanded to the TabINDEX Tab key order ~ Visible control is visible when selecting one contact.
3. Practical skills: 1) How to click on the text (not /-) to expand the (contracted) child node to set the Tree's ShowToolTip property to false.
2) How to display the "Node Name: User /- to Expand / Collapse" when the mouse is pointed out, you can set the TREE's SELECTEXPANDS property to TRUE. 3) Do not show the problem of tree type First: The control package is not installed, try the control package introduced in the use. Second: TreeView requires client browser version of IE5.5 and above, it is best to request client upgrade to IE6.0
4) About flashing the autopostback property set to true, SELECTEDEXCHANGE can be executed. However, this is very powerful. If you don't refresh, set the AutoPostBack property to False.
5) How to automatically select the new node when you move the focus with the keyboard, and perform the new node to set the TREE's AutoSelect property to TRUE.
6) Don't want to display the /- symbol button? Set the Tree's ShowPlus property to false.
7) Do you want to display how to do a hierarchy connection? Set the Tree's Showlines property to false.
8) How to set the icon next to the node ~ ExpandedImageURL, Imageurl, SELECTEDIMAGEURL These 3 attributes are control icons, and choose OK.
4. Take a look at this example, it must be inspired by you, it is a non-grade tree, but it may be a bit in practical use: http://218.56.11.178: 8018 / filedown.aspx? FID = 246
5. This forum also uses a tree (ASP.NET C # MSSQL 2000), and the code is open, if you feel that there is a reference value, you can put it together, which also contains some other common ASP.NET programming skills. Demonstrate how the Tree control combined with the database, dynamically display data in the library, this tree is only two layers, but it is more practical: http://218.56.11.178: 8018 / filedown.aspx? FID = 212 where: Tree.aspx Tree.aspx.cs is the main part of the TREE control used.
The actual application address of the forum is here: http: //expert.kaer.cn/
TreeView uses highlights HGKNIGHT (original)
It turned out to have a special post in the forum, but because some questions can't be found because of the posts, some problems have been found, and this time they have added some, they are sent to the document area for easy inquiry. Original posted http://expert.9cbs.net/expert /topic/1525/1525202.xml
1. Download the address http://msdn.microsoft.com/downloads/samples/internet/DOT_NET_SERVERCONTERNTROLS/WebControls/default.asp Download is the versions of the suffix BAT (1) Bulid. Point Bulid.Bat Ports CSC.exe The path generates Microsoft.Web.ui.WebControls.dll. (2) Creating a empty directory WebCtrl_client / 1_0 under wwwroot. (3) Copy the file under Build / Runtime to WebCtrl_Client / 1_0. (4) Select the custom toolbox for the toolbox, add Microsoft.Web.ui.WebControls.dll. Some trouble but if you can find the suffix is the automatic installation version of MSI, directly next step (I have always used this version, hoho), by "Custom Toolbox" -> ". Net Framework Components" Add TreeView to In the toolbox, 2. It is generally not displayed when running, it is best to download the English version of the automatic installation version, you should first go to the Add Delete program before installation.
3. Display format error (non-tree display) TreeView requires client browser version to IE5.5 and above, it is best to request client upgrade to IE6.0
4. Use TreeView in the framework to set the NaviGateURL, Target property, update additional Frame
5. Can't find the TREENODE class using TreeView, it is best to add Namespace: use Microsoft.Web.ui.WebControls;
6. TreeView node traversal (recursive algorithm) private void Page_Load (object sender, System.EventArgs e) {GetAllNodeText (TreeView1.Nodes);} void GetAllNodeText (TreeNodeCollection tnc) {foreach (TreeNode node in tnc) {if (node.Nodes .Count! = 0) getAllNodeText (Node.Nodes); Response.Write (Node.Text ");}}
7. Get the parent of the Node Node Treenode PNode; if (node.parent is treenode) pnode = (Treenode) node.parent; else // node is root node
8. Modify TreeView pattern (example)
9. When expanded, change the autopostback when it is changed when changing the selection node; add
and write in PageLoad: string stratreename =" TreeView1 "; string strref = Page .GetPostBackeventReference (TreeView1); string strscript = "