473,425 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

Recreate a >>C# WinForms<< TreeView "state" -after- treeview rebuild ?? Any TreeView GODS out there ??

I have a C# WinForms treeview with 20 or so 'level 0' nodes.

My users will normally have 2 of the 'level 0' branches open down to a '5th
level' selected node.

The users will make updates to the 2 selected nodes that will alter the node
name.

I think I need to rebuild the TreeView to get everything synchronized after
they click an update button.

Is there an example somewhere that shows how to recreate and re-expand level
0 branches of the TreeView state after the Tree has been rebuilt?

Put another way ... At the time the user commits an update the Level 0 nodes
5 and 18 are open 'down' to a pair of selected 5th level nodes. One node per
branch. All the other level 0 nodes are collapsed.

How do I rebuild the treeview and open the 5 and 18 level 0 nodes down to
the 5th level and reselect the 5th level nodes that the users had
previously selected and updated ?? I can save the names of the previously
selected and updated nodes. I'm just unsure of how to selectively expand
the 5 and 18 level 0 branches down to the 5th level and reselect the target
nodes.

Any help would be GREATLY appreciated.

Thanks in advance.

Barry in Oregon

Aug 15 '08 #1
4 4976
frostbb wrote:
How do I rebuild the treeview and open the 5 and 18 level 0 nodes down to
the 5th level and reselect the 5th level nodes that the users had
previously selected and updated ?? I can save the names of the previously
selected and updated nodes. I'm just unsure of how to selectively expand
the 5 and 18 level 0 branches down to the 5th level and reselect the target
nodes.
Save the state of ANY node that is expanded. When rebuilding the tree,
after inserting a node and inserting its children, check to see if its
one of your saved expanded nodes, and expand it.
For storing which items are expanded, I'd store the full path to the
node from the root.

--
Joel Lucsy
"The dinosaurs became extinct because they didn't have a space program."
-- Larry Niven
Aug 15 '08 #2

frostbb wrote:
I have a C# WinForms treeview with 20 or so 'level 0' nodes.

My users will normally have 2 of the 'level 0' branches open down to a '5th
level' selected node.

The users will make updates to the 2 selected nodes that will alter the node
name.

I think I need to rebuild the TreeView to get everything synchronized after
they click an update button.
Not necessarily. If you can track the specific changes that are
happening to the data source from which the tree is loaded, you can
avoid the full rebuild, instead just inserting, removing or moving the
nodes that were changed. And that will preserve the collapsed/expanded
state of all nodes.
Aug 15 '08 #3
Thanks for the reply. Hadn't considered simply dropping and recreating the
existing nodes. In this case I may actully be able to get away with that!
I'm pretty sure I can get this thing to work using your and the other
replies to my question.

Best wishes. Happy computing and THANKS!

Barry in Oregon

"Pavel Minaev" <in****@gmail.comwrote in message
news:9c**********************************@f36g2000 hsa.googlegroups.com...
>
frostbb wrote:
>I have a C# WinForms treeview with 20 or so 'level 0' nodes.

My users will normally have 2 of the 'level 0' branches open down to a
'5th
level' selected node.

The users will make updates to the 2 selected nodes that will alter the
node
name.

I think I need to rebuild the TreeView to get everything synchronized
after
they click an update button.

Not necessarily. If you can track the specific changes that are
happening to the data source from which the tree is loaded, you can
avoid the full rebuild, instead just inserting, removing or moving the
nodes that were changed. And that will preserve the collapsed/expanded
state of all nodes.

Aug 18 '08 #4
Joel,

Thanks for the reply. Really appreciate your time and knowledge. I'm pretty
sure I can get this to work using your
and the other replies to my question.

Best wishes. Happy computing and THANKS!

Barry in Oregon
"Joel Lucsy" <jj*****@gmail.comwrote in message
news:Ob**************@TK2MSFTNGP04.phx.gbl...
frostbb wrote:
>How do I rebuild the treeview and open the 5 and 18 level 0 nodes down to
the 5th level and reselect the 5th level nodes that the users had
previously selected and updated ?? I can save the names of the
previously selected and updated nodes. I'm just unsure of how to
selectively expand the 5 and 18 level 0 branches down to the 5th level
and reselect the target nodes.

Save the state of ANY node that is expanded. When rebuilding the tree,
after inserting a node and inserting its children, check to see if its one
of your saved expanded nodes, and expand it.
For storing which items are expanded, I'd store the full path to the node
from the root.

--
Joel Lucsy
"The dinosaurs became extinct because they didn't have a space
program." -- Larry Niven

Aug 18 '08 #5

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

Similar topics

13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
7
by: Andreas Prilop | last post by:
Internet Explorer displays <tt>, <code> etc. in a smaller font size: http://www.unics.uni-hannover.de/nhtcapri/temp/monospace.html I don't like the idea that monospaced text is displayed in a...
22
by: Dr Duck | last post by:
GDay all, Something seems odd to me.... I wrote a simple C# function public void bind(ref object a, ref object b, bool atob) { if(atob) b = a; else
9
by: shannonl | last post by:
Hi all, For some reason this bind is calling the donothing function, like it should, but is then allowing the text to be inserted into the Text widget. Here is the code: ...
1
by: Kelvin | last post by:
Hi All, I try to use the following microsft resolution web site, but still have same problem. http://support.microsoft.com/default.aspx?scid=kb;en-us;555074 I put the source code on...
1
by: Kelvin | last post by:
Hi All, "disable view state for the datagrid." How to do that ? Please advise ! Here is also attached my sources code ------------------------------------------- void DetailGrid_setPage (...
2
by: Jason Huang | last post by:
Hi, Kind of spending too much time on the no-cache issue and found out something like <% Response.CacheControl = "no-cache" %>. In my ASP.Net, a C# .aspx file, where do I put the <%...
13
by: Water Cooler v2 | last post by:
What do you mean by a cookieless session state? When you set the sessionState section's cookieless attribute to true in the web.config file, what does that mean? I read this...
6
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - I have <a href="javascript:somefunction()"what .... ?...
1
by: Brit | last post by:
I have an ASP file that retrieves names from an Access database for 4 different categories of membership, which the visitor to the page selects (corporate, institutional, regular, or student). The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
0
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...
0
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...

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.