473,618 Members | 3,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

urgent please : treeview control expand collapse

how can i collapse or expand a node of treeview control programmaticly?
thanks.
Nov 17 '05 #1
4 3396
each node contains a collapse property have a look at your object browser
"Gönen EREN" <ge***@gsu.edu. tr> wrote in message
news:OR******** ******@TK2MSFTN GP10.phx.gbl...
how can i collapse or expand a node of treeview control programmaticly?
thanks.

Nov 17 '05 #2
There is an event handler collapse but i couldn't find a collapse or expand
method
for example for a treeview object like :

<iewc:TreeVie w id="MenuTree" runat="server"
onselectedindex changed="MenuTr eeSelectChanged ">
<iewc:TreeNod e Text="A"></iewc:TreeNode>
<iewc:TreeNod e Text="B">
<iewc:TreeNod e Text="B1"></iewc:TreeNode>
<iewc:TreeNod e Text="B2"></iewc:TreeNode>
<iewc:TreeNod e Text="B3"></iewc:TreeNode>
<iewc:TreeNod e Text="B4"></iewc:TreeNode>
</iewc:TreeNode>
<iewc:TreeNod e Text="C">
<iewc:TreeNod e Text="C1"></iewc:TreeNode>
<iewc:TreeNod e Text="C2"></iewc:TreeNode>
<iewc:TreeNod e Text="C3"></iewc:TreeNode>
</iewc:TreeNode>
</iewc:TreeView>

what should i use in

public void MenuTreeSelectC hanged(Object sender, TreeViewSelectE ventArgs e)
{

}

i want only the the "e.NewNode" to be expanded and collapse the "e.OldNode"

thanks for your help.
"Alvin Bruney" <vapordan_spam_ me_not@hotmail_ no_spamhotmail. com> wrote in
message news:OF******** *****@tk2msftng p13.phx.gbl...
each node contains a collapse property have a look at your object browser
"Gönen EREN" <ge***@gsu.edu. tr> wrote in message
news:OR******** ******@TK2MSFTN GP10.phx.gbl...
how can i collapse or expand a node of treeview control programmaticly?
thanks.


Nov 17 '05 #3
"Gönen EREN" <ge***@gsu.edu. tr> wrote in message
news:e3******** ******@TK2MSFTN GP09.phx.gbl...
....
what should i use in

public void MenuTreeSelectC hanged(Object sender, TreeViewSelectE ventArgs e) {

}

i want only the the "e.NewNode" to be expanded and collapse the "e.OldNode"
thanks for your help.


Give this a try. I haven't tested it, but it compiles:

public void MenuTreeSelectC hanged(Object sender, TreeViewSelectE ventArgs e)
{
TreeView treeView = (TreeView) sender;

TreeNode oldNode = treeView.GetNod eFromIndex(e.Ol dNode);
oldNode.Expande d = false;

TreeNode newNode = treeView.GetNod eFromIndex(e.Ne wNode);
newNode.Expande d = true;
}

--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com
Nov 17 '05 #4
it compiles but it doesn't work =(
i have also tried this one but the same thing no effect...
do you have any other ideas?

i use code behind, my code looks like:
------------------------------------------------------------
[...]

<iewc:TreeVie w id="MenuTree" runat="server"
onselectedindex changed="MenuTr eeSelectChanged ">
<iewc:TreeNod e Text="A"></iewc:TreeNode>
<iewc:TreeNod e Text="B">
<iewc:TreeNod e Text="B1"></iewc:TreeNode>
<iewc:TreeNod e Text="B2"></iewc:TreeNode>
<iewc:TreeNod e Text="B3"></iewc:TreeNode>
<iewc:TreeNod e Text="B4"></iewc:TreeNode>
</iewc:TreeNode>
<iewc:TreeNod e Text="C">
<iewc:TreeNod e Text="C1"></iewc:TreeNode>
<iewc:TreeNod e Text="C2"></iewc:TreeNode>
<iewc:TreeNod e Text="C3"></iewc:TreeNode>
</iewc:TreeNode>
</iewc:TreeView>

[...]
------------------------------------------------------------

namespace ControlCenter
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using Microsoft.Web.U I.WebControls;

public abstract class Menu : System.Web.UI.U serControl
{
protected Microsoft.Web.U I.WebControls.T reeView MenuTree;

private void Page_Load(objec t sender, System.EventArg s e){}

public void MenuTreeSelectC hanged(Object sender,
TreeViewSelectE ventArgs e)
{
// This doesn't work...
MenuTree.GetNod eFromIndex(e.Ol dNode).Expanded =false;
MenuTree.GetNod eFromIndex(e.Ol dNode).Expanded =true;
}

//region Web Form Designer generated code
[...]
}
}

------------------------------------------------------------
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2422
by: Stephen | last post by:
In asp.net 1.1, the IE treeview web control has a property called "SelectExpands" that, when set to true, expands a node when a user clicks the node text. I can't seem to replicate this in the treeview control in .net 2.0. Anyone know of way to expand a node when a users clicks the node text?
1
1812
by: christoffer.lantz | last post by:
Howdy folks. Would anyone care to suggest a way to have sibling nodes (at the same level) collapse when a node is expanded in an asp.net 2.0 treeview control? What I mean is that I want only one subtree to be open at a time. Can the treeview control do this by itself or is some fiddeling required? Regards, Lantz
1
1905
by: vivek | last post by:
Well I have been using the new Microsoft asp.net 2.0 TreeView Control in my application. I need to provide some kind of "Expand All" and "Collapse All" button. This button should not post the form back to the server but should work by Javascript only. Any suggestion is welcome. Thanks Vivek N
0
2553
by: Shadow Lynx | last post by:
When using ASP.NET 2.0's built-in TreeView on a page with <BASE target = "AnythingBut_Self"></BASE> in the HEAD, the expand/collapse buttons fail to function. The reason for this is that the hyperlinks generated for the expand/collapse buttons includes javascript code that will execute in the frame specified in the Base Target rather than the current document. To remedy this, TreeView should render a target="_self" attribute for each...
3
2248
by: Shawn | last post by:
Hi. I'm working with the TreeView control in my ASP.NET 1.1 application. I have a problem I haven't been able to figure out. When I click on a node (not expand), whether it's a parent node, a child node or a leaf node then a DataGrid is populated based on the node's ID property. If I expand a node then the DataGrid is not populated. This works fine. The problem is that this doesn't work if I collapse the tree. If I collapse the tree...
0
1111
by: Tor Inge Rislaa | last post by:
Controlling the TreeView I have the sitemap below as source for my TreeView control. When I open my application I want only the nodes Home, About, Products and Contact to show. The child nodes of Products (Product1 and Product1) should reveal when the user click on the title Products. <?xml version="1.0" encoding="utf-8" ?> <siteMap>
0
5253
by: Tor Inge Rislaa | last post by:
I need to expand/collapse TreeView nodes to show/hide childnodes by clikcing on the node text (instead of using the expand/collapse icon). Does anyone know how to do that? (What property has to be set on the TreeView control?) My control I bound to a web.sitemap as below: <?xml version="1.0" encoding="utf-8" ?> <siteMap> <siteMapNode title="Home" url="Default.aspx"> <siteMapNode title="About" url="About.aspx" />
0
2336
by: Tor Inge Rislaa | last post by:
Controlling TreeView Expand/Collapse With a TreeView bound to an XML file as below I want to obtain the functionality where Chapter 2 and 3 are forced to collapse when Chapter 1 is selected and Chapter 1 and 3 collapses when Chapter 2 is selected and so on.
6
2207
by: Andrew Poulos | last post by:
I need to create a treeview control with the following options: - expand/collapse all - the small plus/minus images next to nodes that can expand/collapse - assign images to each node - dynamically assign an image to a node Can anyone recommend a suitable one? Andrew Poulos
0
8207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8150
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7124
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6098
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5552
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4064
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2582
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.