473,597 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4991
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.c omwrote in message
news:9c******** *************** ***********@f36 g2000hsa.google groups.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******** ******@TK2MSFTN GP04.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
40688
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 style="display:none"> can be displayed by setting the style attribute to "display:", or hidden with "display:none". This gives the illusion that the person filling out the form is switching from page to page...without the overhead of extra hits on the server,...
7
3082
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 different size. Should we state "font-size: 100%" with monospaced text? -- Meanwhile at the Google Ranch ... "I can't read this bloody site; it's all Falsh and JavaScrap." "Forget it and move on! Still 2 718 281 828 pages to crawl."
22
3323
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
2748
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: self.framebody.tag_config("name", underline=1) self.framebody.tag_bind("name", "<Any-KeyPress>", self.donothing)
1
2182
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 "DataGrid_setPage" try
1
1487
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 ( Object src, DataGridPageChangedEventArgs e ) {
2
16671
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 <% Response.CacheControl = "no-cache" %>? Is this enough to fix the Caching bug? Thanks for help. Jason
13
3543
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 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfSessionstateSection.asp) and it does not explain the meaning of cookieless.
6
463
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - I have <a href="javascript:somefunction()"what .... ? ----------------------------------------------------------------------- Whatever the rest of your question, this is generally a very bad use of the javascript pseudo protocol. It was designed so that a function could return a new page. For example: ` javascript:"<p>Hello</p>" `. Using it simply to...
1
2356
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 DNS name is "cati", the names are specified in the "Last_names" field, and the categories are in the "categories" field. l want the results sorted in alphabetic order by last name. However, the results appear to be in a totally random,...
0
7979
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
8281
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...
1
8046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8262
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...
1
5847
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
5437
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
3937
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1497
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1245
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.