Sign in to follow this  
Followers 0
Ghost21

Update Treeview Items text

6 posts in this topic

Trying to update the selected item with the correct text

$ID = _GUICtrlTreeView_GetSelection($TreeView1)

_GUICtrlTreeView_BeginUpdate($TreeView1)

_GUICtrlTreeView_SetText($TreeView1, $ID, $PC)

_GUICtrlTreeView_SetText($TreeView1, $ID + 1, $IP)

_GUICtrlTreeView_SetText($TreeView1, $ID + 2, $Ping)

_GUICtrlTreeView_SetText($TreeView1, $ID + 3, $User)

_GUICtrlTreeView_SetText($TreeView1, $ID + 4, $Acctlocked)

_GUICtrlTreeView_SetText($TreeView1, $ID + 5, $Contactnumber)

_GUICtrlTreeView_SetText($TreeView1, $ID + 6, $Department)

_GUICtrlTreeView_SetText($TreeView1, $ID + 7, $Lastupdate)

_GUICtrlTreeView_EndUpdate($TreeView1)

_GUICtrlTreeView_SelectItem($TreeView1, $ID)

I'm sure its just something stupid I have missed... Can somone kick my A :idea: in the right direction...

Share this post


Link to post
Share on other sites

Can't run an incomplete script. Post a short RUNNING demo to reproduce your symptoms.

So, what happens when you try it? What fails? What are the symptoms? How is the selection made, and how do you know there will be at least seven more items after the selected one (what if the last one is selected)?

:idea:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Can't run an incomplete script. Post a short RUNNING demo to reproduce your symptoms.

So, what happens when you try it? What fails? What are the symptoms? How is the selection made, and how do you know there will be at least seven more items after the selected one (what if the last one is selected)?

:idea:

I'm populating a list of pcs and if I only want to update that one record I first select it then right click and say update single record. The backend database updates but the text on the treeview doesn't change..

Share this post


Link to post
Share on other sites

_GUICtrlTreeView_GetSelection returns a handle to an item. You can't just add numbers to it to specify a child or next item. If they are children of the selected item, then you need to do something like this:

$hItem = _GUICtrlTreeView_GetSelection($TreeView1)
_GUICtrlTreeView_SetText($hTreeView, $hItem, "You are horrible")
$hChild = _GUICtrlTreeView_GetFirstChild($TreeView1, $hItem)
While $hChild <> 0
    _GUICtrlTreeView_SetText($TreeView1, $hChild, "You are a horrible child")
    $hChild = _GUICtrlTreeView_GetNextChild($TreeView1, $hChild)
WEnd

If they are just sibling items then you need to use _GuiCtrlTreeView_GetNextSibling.

Share this post


Link to post
Share on other sites

I think you are misunderstanding how the TreeView UDF functions work. Your $ID is a HWND (handle) not a control ID or index. You can't address the next item with $ID + 1. More likely, $ID looks something like 0x00C8A2D0, and the next item's handle is like 0x00C8A3E4.

So, are you trying to update items on the same level, or are those child items of the parent represented by $ID?

To update seven child items of $ID, get the handle of the first with _GUICtrlTreeView_GetFirstChild() and update it, then get each subsequent child off the previous one with _GUICtrlTreeView_GetNextSibling().

:idea:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I think you are misunderstanding how the TreeView UDF functions work. Your $ID is a HWND (handle) not a control ID or index. You can't address the next item with $ID + 1. More likely, $ID looks something like 0x00C8A2D0, and the next item's handle is like 0x00C8A3E4.

So, are you trying to update items on the same level, or are those child items of the parent represented by $ID?

To update seven child items of $ID, get the handle of the first with _GUICtrlTreeView_GetFirstChild() and update it, then get each subsequent child off the previous one with _GUICtrlTreeView_GetNextSibling().

:idea:

Ahhh yes that makes sense now... Thank you all for the help...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0