473,411 Members | 2,154 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,411 software developers and data experts.

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(&H7120C0)

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

For L = 0 To 49
player = hostvalue + (668 * L)
name = ReadAscii(player + 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 2493
On Jun 19, 11:07 am, Tom <tomrleigh...@gmail.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(&H7120C0)

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

For L = 0 To 49
player = hostvalue + (668 * L)
name = ReadAscii(player + 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
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. ...
3
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....
1
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...
1
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...
0
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...
0
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,...
0
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...
10
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...
6
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...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...
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...

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.