473,614 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TreeView help please

In a treeview, I am trying to store the index of every treenode as it expands
in a hidden input box. If I click on the node itself, it expands and I can
capture the node index no problem. If I click on the plus sign however, the
selected index doesn't change so I can't capture the index of the newly
expanded node. Does any one know how to change the selected node when a plus
sign is clicked?
Nov 19 '05 #1
2 1352
Something to keep in mind is that expanding is not the same as selecting a
node. By default, a node that is selected can also fire an expanded event.
Expanding a node therefore doesn't necessarily select it. You have to
capture the Expand event with your own handler. Let's say we had a tree
named objTree. Capturing the node that was expanded may look something like
this:

private void objTree_Expand( object sender, TreeViewClickEv entArgs e)
{
TreeNode objNode = (TreeNode)e.Nod e;
string strIndex = objNode.GetNode Index();
}

You could probably even set the current index to equal the expanded node.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"clsmith66" <cl*******@disc ussions.microso ft.com> wrote in message
news:68******** *************** ***********@mic rosoft.com...
In a treeview, I am trying to store the index of every treenode as it
expands
in a hidden input box. If I click on the node itself, it expands and I
can
capture the node index no problem. If I click on the plus sign however,
the
selected index doesn't change so I can't capture the index of the newly
expanded node. Does any one know how to change the selected node when a
plus
sign is clicked?

Nov 19 '05 #2
Thank you Mark for your quick response. I was finaly able to track the node
indexes(?) I needed by using the treeviews Expand event but I have a minor
problem with the click event. This is what I did:
1. Set the tree to AutoPostBack=tr ue
2. Set the IsPostBack in the Page_Load to exit sub if true
3. Code in expand event is only one line. It sets the value of a hidden
field equal to the index of the e.Node argument.
All this works but every time I expand a node now I have a delay of approx.
10 seconds before I can do anything else on the page. Any ideas why? The
page is large with three tabs and three treeviews but if the IsPostBack is
set to only exit the page_load shouldn't that skip all the building of the
page and return control back to the user? Thanks for any clues you might be
able to offer.

"Mark Fitzpatrick" wrote:
Something to keep in mind is that expanding is not the same as selecting a
node. By default, a node that is selected can also fire an expanded event.
Expanding a node therefore doesn't necessarily select it. You have to
capture the Expand event with your own handler. Let's say we had a tree
named objTree. Capturing the node that was expanded may look something like
this:

private void objTree_Expand( object sender, TreeViewClickEv entArgs e)
{
TreeNode objNode = (TreeNode)e.Nod e;
string strIndex = objNode.GetNode Index();
}

You could probably even set the current index to equal the expanded node.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"clsmith66" <cl*******@disc ussions.microso ft.com> wrote in message
news:68******** *************** ***********@mic rosoft.com...
In a treeview, I am trying to store the index of every treenode as it
expands
in a hidden input box. If I click on the node itself, it expands and I
can
capture the node index no problem. If I click on the plus sign however,
the
selected index doesn't change so I can't capture the index of the newly
expanded node. Does any one know how to change the selected node when a
plus
sign is clicked?


Nov 19 '05 #3

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

Similar topics

4
5256
by: Jeroen Ceuppens | last post by:
Hi, I want to make something that adds a TreeNode to the end of TreeView, that TreeView Looks like + Level 1 + Level 2 + Level 3 - Level last
2
2421
by: Sonia Igla | last post by:
Hi. I need to perform DBLCLK on TreeView Node. I try the following: private static extern int SendMessage(IntPtr hWnd, uint msg, UInt32 wParam, UInt32 lParam); private const UInt32 WM_LBUTTONDBLCLK = 0x203; pTreeNode.TreeView.SelectedNode = pTreeNode;
3
2159
by: Peter | last post by:
Hello Thanks for reviewing my question. I would like to know how can I programmatically select a node Thanks in Advanc Peter
14
6813
by: Evan Kontos | last post by:
I am trying to implement a Treeview w/an XML file and I even copied and pasted examples from MSDN but can't get them to work. Any suggestions welcome. XML File <TREENODES> <TREENODE TEXT="Document-1"> <TREENODE TEXT="Folder-1" EXPANDED="true"> <TREENODE TEXT="Document-2" />
2
2589
by: pmcguire67 | last post by:
There has been a lot of discussion lately about extending the treeview control to allow finding a node by key rather than by index. Everyone seems to agree that a hashtable is needed to accomplish this. Also, there is a KB article (http://support.microsoft.com/default.aspx?scid=kb;en-us;311318) purporting to show you how to extend the treenode to include a key. This article seems to be nearly useless to me, as (despite adding a...
14
15077
by: Mr.D | last post by:
How do I save/load the contents of a Treeview to a file? I have found several good examples written i VB6, but not a single one for VB.NET. Please help. ---- Tim
1
693
by: kvicky | last post by:
I am trying to load child nodes to a TreeNode in a TreeView in a ASP.net web application. The Treeview with parent nodes are loaded on a Page_load while doing if( ! ISPostback ) and then in the Treeview event I am dynamically trying to load the child nodes to the exisisting TreeView. The problem is since the TreeView is being loaded on not a Postback, I am unable to refer to any node in the TreeView event. Can anybody tell me how to...
1
2104
by: | last post by:
What's the best way to create new nodes on a treeview 2.0 and save them to an xml file? Thanks, Victor
18
15357
by: =?Utf-8?B?TGkgV2VuZw==?= | last post by:
Hi, Is there a way for TreeView to have multiple selections? But I am not talking about its checked boxes. I want a way similar to ListView with MultiSelect = True. So I can use or key and click to make multiple selections. Then when I simply click one item, all previous selections are gone. Thanks in advance.
5
7512
by: Max2006 | last post by:
Hi, I have a TreeView and this is my node style: <asp:TreeNodeStyle ForeColor = "#000000" Font-Size="9px" Font-Bold="false" Width="100px" NodeSpacing="3px" /> The problem is the expand button (+) resides right at the middle of multi-line text. Can I make the expand button top align instead of middle align?
0
8182
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
8130
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
8627
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8433
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
7093
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
6088
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
5540
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();...
1
2568
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
0
1425
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.