473,659 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updating Nodes in a treeview without deselecting current node

Tom
Hey,

I have a treeview control which i am reading and writing slots to (Its a
player manager for Delta Force Black Hawk Down).

At the moment, every 100ms it reads through the games memory to retreive
the player info, which i can parse. Problem is is that if you have an
item selected, when it clears and remakes all the nodes it deselects the
one selected, making it pretty useless to select players to view details.

Does anyone have a foolproof method to update a treeview while keeping
the currently selected node selected?
/// Begin Code

Dim L As Long
Dim hostvalue As Long
Dim player As Long
Dim name As String

hostvalue = ReadALong(&H712 0C0)

tvPlayers.Nodes ("root").Nodes. Clear()

For L = 0 To 49
player = hostvalue + (668 * L)
name = ReadAscii(playe r + 200, 16)
If name <"" Then
Dim newnode As TreeNode = New TreeNode
newnode.Text = L + 1 & ") " & name
newnode.Tag = player
tvPlayers.Nodes ("root").Nodes. Add(newnode)
End If

Next L

Cheers

Tom
Jun 19 '07 #1
1 2506
On Jun 19, 11:07 am, Tom <tomrleigh...@g mail.comwrote:
Hey,

I have a treeview control which i am reading and writing slots to (Its a
player manager for Delta Force Black Hawk Down).

At the moment, every 100ms it reads through the games memory to retreive
the player info, which i can parse. Problem is is that if you have an
item selected, when it clears and remakes all the nodes it deselects the
one selected, making it pretty useless to select players to view details.

Does anyone have a foolproof method to update a treeview while keeping
the currently selected node selected?

/// Begin Code

Dim L As Long
Dim hostvalue As Long
Dim player As Long
Dim name As String

hostvalue = ReadALong(&H712 0C0)

tvPlayers.Nodes ("root").Nodes. Clear()

For L = 0 To 49
player = hostvalue + (668 * L)
name = ReadAscii(playe r + 200, 16)
If name <"" Then
Dim newnode As TreeNode = New TreeNode
newnode.Text = L + 1 & ") " & name
newnode.Tag = player
tvPlayers.Nodes ("root").Nodes. Add(newnode)
End If

Next L

Cheers

Tom
Assuming there is a unique id for a player, why not store that value,
update the treeview, and then loop back through the nodes and re-
select it? Or possibly, instead of clearing all the nodes with
Nodes.Clear(), you could loop through and remove all but the selected
node. Then in your loop that adds the new nodes, skip adding the node
if the new node equals the selected node.

Thanks,

Seth Rowe

Jun 19 '07 #2

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

Similar topics

2
22023
by: Jack | last post by:
Hello, I am trying use a TreeView with checkboxes. I would like to check more than one node and allow all child nodes of selected nodes to be checked or unchecked with the parent is checked. Thanks in advance for any help, Jack
3
12140
by: juvi | last post by:
Hi, I have got a problem with Treeview.Nodes.Clear() under VB2005. When I have some nodes in my treeview and a force to clear() all nodes then it seems to work, because the nodes are not visible. But when I add new nodes and I want to look for a specific item then I only get the Items from the beginning --> something is not working with the clear() method. Please help me!?! juvi
1
3272
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file exists just to sort of synchronize them by changing the xml nodes attribute(s). somehow i always catch an exception "blabla has an invalid token" but i cannot find a solution for this. maybe someone of you people can tell me how to do this...
1
2596
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file exists just to sort of synchronize them by changing the xml nodes attribute(s). somehow i always catch an exception "blabla has an invalid token" but i cannot find a solution for this. maybe someone of you people can tell me how to do this...
0
2287
by: drop | last post by:
Hi, I'm currently working with the Treeview control in ASP .Net 2.0. The tree is filled dynamically based on data contained in a MySQL Database. Here is the exact behavior I want : 1 - User clicks on a node to expand it. 2 - Add a child node to the node clicked by the user saying the tree is loading that part. So here, I also need to expand the node clicked by
0
1124
LacrosseB0ss
by: LacrosseB0ss | last post by:
Hey all! I have just started using the TreeView object in asp. There are some other applications I have seen use it and I have copied some of the code from them at work. What happens is on a form, an item is selected from a dropdown box and based on what the user selects, there are items linked to that group in a different field. I would like these items to show up as tree view nodes split aplhabetically. This works fine. The grandparent...
0
1896
by: Falcula | last post by:
Hello, I have a treeview that i fill from a database, when i update nodename in database the treeview dont update. Its works when iam not useing enableviewstate="true" but then i loosing the current selection and stuff in the tree. I post my code here, any idea ?
10
34468
by: John Rogers | last post by:
This code only counts the parent nodes or rootnodes in a treeview, how do you count all the nodes in a treeview? // one way int NodeCounter = 0; foreach (TreeNode currentNode in TreeView1.Nodes) NodeCounter++; // other way int total = TreeView1.Nodes.Count;
6
4058
Sl1ver
by: Sl1ver | last post by:
I've got a problem, i got the nodes to move but 1. they copy nodes(if you drag it to 3 different places it will actually have 3 of the same nodes) 2. i want to make the nodes, if moved update the new nodes locations This is my coding private void tvDescriptions_MouseDown(object sender, MouseEventArgs e) { TreeView tree = (TreeView)sender;
0
8341
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
8630
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
7360
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
6181
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
4176
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
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2759
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
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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.