Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Moving Data With Dragging A Treeview Node


i want to move data about a Database connection , from the treeview to a listbox.

i know i could use a ADODB recordset....any ideas how ?

thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
TreeView - Dragging And Dropping A Node In The Middle Of A Level
Does anyone know how to drag and drop a node within a treeview control in the middle of a level on the same treeview control?

When I use the drag and drop methods, and drop my node on a level I can drop it as the first child under that level or I can drop it as the first node at the same level.

IfI have 5 nodes under a level and want to drop another node in between nodes 3 and 4, it will only drop it before node 1.

Does anyone out there have any codes samples that they are using themselves to do this?

I have search the internet for samples and can not find one that does this.

Show Item Text When Dragging A Treeview Node
Does anybody know how when dragging a treeview node, to display the text property of the node as well as the DragIcon. I want to be able to replate the drag drop behaviour of Windows Explorer, i.e while you are dragging a folder, you can see the folder name in transparent text.

I have no problem setting the DragIcon property from an imageList I have associated with the treeview. For example in the DragOver event I am setting the DragIcon based on whether the mouse is over a valid drop point. E.g. .DragIcon = LoadResPicture("NoDrop", vbResCursor)

However it only shows the DragIcon and nothing else when dragging the node. Any help appreciated.

Need Help Debugging Memory Leak Using APIs To View Treeview Node While Dragging
Hi all,

A long time VB hacker here.

This code is actually working with the first 7 drag and drops but stops working properly on the 8th attempt.

This is the least amount of code I've been able to find to:
View Treeview Node While Dragging.
AND works (well, kind of..) with mscomctl.ocx (v6)


I'm using Microsoft Windows Common Controls 6.0
in VB6 with SP5.

Any help in sorting this problem out and maybe cleaning this code up would be greatly appreciated.

Hopefully, other contributors will find this usefull as well.

Thanks,
Barry G. Sumpter

-----------

Note: This code uses the SetTimer API and exits VB if you stop execution while the timer is still enabled/running.

Only the form_load event code is mine. As well as the Debug.Prints

I've moved all the code that is in module from form1.
I just couldn't get anything to work otherwise. (I AM a hack )

-----------------------

Form1:
-----
Form1 Has 1 Treeview Control Named TreeView3
.....TreeView3 has Style set to 7 - tvwTreelinesPlusMinusPictureText
Form1 Has 1 ImageList Control Name ImageList1
.....ImageList1 which contains 4 16x16 icons with the Use Mask Color Ticked ON

-----------------------

Option Explicit


Public Sub DragComplete()

Debug.Print Now & "- " & "DragComplete"
'
' DragComplete
'
' Removes the drag image
'

' Stop the timer
KillTimer 0, m_lTimer

' End the image dragging
ImageList_EndDrag

' Destroy the ImageList
ImageList_Destroy m_lIL

End Sub


Public Sub TreeView_StartDrag( _
ByVal hWndTreeView As Long, _
Optional ByVal x As Long = 20, _
Optional ByVal y As Long = 20)


Debug.Print Now & "- " & "TreeView_StartDrag"


Dim tPoint As POINTL
Dim hItem As Long

' Get the selected node
hItem = SendMessage(hWndTreeView, TVM_GETNEXTITEM, TVGN_DROPHILITE, ByVal 0&)

' Get a ImageList with the drag image
m_lIL = SendMessage(hWndTreeView, TVM_CREATEDRAGIMAGE, 0, ByVal hItem)

' Start the image dragging
ImageList_BeginDrag m_lIL, 0, x, y
ImageList_DragEnter 0, 0, 0

' Start the timer
m_lTimer = SetTimer(0, 0, 1, AddressOf pvTimerDragMove)

End Sub


Private Sub TreeView3_OLECompleteDrag(Effect As Long)

Debug.Print Now & "- " & "TreeView3_OLECompleteDrag"

DragComplete

End Sub

Private Sub TreeView3_OLEStartDrag(Data As MSComctlLib.DataObject, AllowedEffects As Long)

Debug.Print Now & "- " & "TreeView3_OLEStartDrag"

' Stop the timer
KillTimer 0, m_lTimer

TreeView_StartDrag TreeView3.hWnd

End Sub
Private Sub Form_Unload(Cancel As Integer)

Debug.Print Now & "- " & "Form_UnLoad"

DragComplete

End Sub


Private Sub Form_Load()

Debug.Print Now & "- " & "Form_Load"

Dim nodx As Node

Set nodx = TreeView3.Nodes.Add(, , "R", "Root", 1)

Set nodx = TreeView3.Nodes.Add("R", tvwChild, "C1", "Child 1", 2)
Set nodx = TreeView3.Nodes.Add("R", tvwChild, "C2", "Child 2", 2)
Set nodx = TreeView3.Nodes.Add("R", tvwChild, "C3", "Child 3", 2)
Set nodx = TreeView3.Nodes.Add("R", tvwChild, "C4", "Child 4", 2)

Set nodx = TreeView3.Nodes.Add("C1", tvwChild, "C1-1", "Child 1-1", 3)
Set nodx = TreeView3.Nodes.Add("C2", tvwChild, "C2-1", "Child 2-1", 3)
Set nodx = TreeView3.Nodes.Add("C3", tvwChild, "C3-1", "Child 3-1", 3)
Set nodx = TreeView3.Nodes.Add("C4", tvwChild, "C4-1", "Child 4-1", 3)

Set nodx = TreeView3.Nodes.Add("C2-1", tvwChild, "C2-1-1", "Child 2-1-1", 4)

Set nodx = TreeView3.Nodes.Add("C3-1", tvwChild, "C3-1-1", "Child 3-1-1", 4)
Set nodx = TreeView3.Nodes.Add("C3-1", tvwChild, "C3-1-2", "Child 3-1-2", 4)

Set nodx = TreeView3.Nodes.Add("C4-1", tvwChild, "C4-1-1", "Child 4-1-1", 4)
Set nodx = TreeView3.Nodes.Add("C4-1", tvwChild, "C4-1-2", "Child 4-1-2", 4)
Set nodx = TreeView3.Nodes.Add("C4-1", tvwChild, "C4-1-3", "Child 4-1-3", 4)

Dim I As Integer

For I = 1 To TreeView3.Nodes.Count
Set nodx = TreeView3.Nodes(I)
nodx.EnsureVisible
Next

TreeView3.BorderStyle = vbFixedSingle

End Sub

-------------------------------------------------
Module 1
-----

Option Explicit

' ==== Public members ====
Public m_lIL As Long
Public m_lTimer As Long

' ==== API declarations ====

Public Declare Function ImageList_BeginDrag Lib "comctl32" ( _
ByVal himlTrack As Long, _
ByVal iTrack As Long, _
ByVal dxHotspot As Long, _
ByVal dyHotspot As Long) As Long

Public Declare Sub ImageList_EndDrag Lib "comctl32" ()

Public Declare Function ImageList_DragEnter Lib "comctl32" ( _
ByVal hwndLock As Long, _
ByVal x As Long, _
ByVal y As Long) As Long

Public Declare Function ImageList_DragLeave Lib "comctl32" ( _
ByVal hwndLock As Long) As Long

Public Declare Function ImageList_DragMove Lib "comctl32" ( _
ByVal x As Long, _
ByVal y As Long) As Long

Public Declare Function ImageList_Destroy Lib "comctl32" ( _
ByVal himl As Long) As Long

Public Declare Function ImageList_GetImageCount Lib "comctl32" ( _
ByVal himl As Long) As Long

Public Type POINTL
x As Long
y As Long
End Type

Public Declare Function GetCursorPos Lib "user32" ( _
lpPoint As POINTL) As Long

Public Declare Function WindowFromPoint Lib "user32" ( _
ByVal xPoint As Long, _
ByVal yPoint As Long) As Long

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long

Public Const LVNI_SELECTED = &H2
Public Const LVNI_DROPHILITED = &H8
Public Const LVM_CREATEDRAGIMAGE = &H1000& + 33
Public Const LVM_GETNEXTITEM = &H1000& + 12

Public Const TVM_CREATEDRAGIMAGE = &H1100& + 18
Public Const TVM_GETNEXTITEM = &H1100& + 10
Public Const TVGN_DROPHILITE = &H8

Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Public Declare Function GetWindowRect Lib "user32" ( _
ByVal hWnd As Long, _
lpRect As RECT) As Long

Public Declare Function KillTimer Lib "user32" ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long

Public Declare Function SetTimer Lib "user32" ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long

Public Sub pvTimerDragMove( _
ByVal hWnd As Long, _
ByVal uMsg As Long, _
ByVal idEvent As Long, _
ByVal dwTime As Long)


Dim tPoint As POINTL

' Get the cursor position
GetCursorPos tPoint

' Move the image to the new cursor position
ImageList_DragMove tPoint.x, tPoint.y

End Sub


-----------------

Thanks again ...

Moving Treeview Node
I'm currently programming a treeview that as the possibility to move a node between two others. Does anyone know how or a place that I should check for that ...


Node1
----node1.1
----node1.2
----node1.3

when I'll drag the node node1.3 and move upward I want that this node goes between the node node1.2 and node1.1 ...


Thank you,

MOVING TO NEXT NODE In A Treeview (solved)
How to determine if SOMETHING is selected in a treeview?

THIS IS THE QUESTION OF THE OLD TOPIC NAME SEE LAST POST

Moving A Node From A Treeview To Another Treeview
I have created a program that displays 2 treeviews, let's call them treeview1 and treeview1. The content of the nodes are taken from 2 different xml files. I would just like to know how i can click, drag and drop a node from treeview1 to treeview2. thanks!

Save/Load Treeview Node With Data
Hi all,
i have a treeview and 3 textbox on my form. --->

treeview textbox1 : Site Name
textbox2 : Number
textbox3 : Comment

the problem is how i'm going to save all the data with the treeview node with using only textfile. when run the program, all the data will be load in the textboxs follow the node that the user click.

Treeview - (un)check All Children Node If Parent Node Is (un)checked
Hi guy,

I have a treeview where I want to automaticly checkuncheck all the children of a parent node when the parent node is checked/unchecked. For this purpose I thought up the following code:


Code:
Private Sub Treeview1_NodeCheck(ByVal CheckedNode As MSComctlLib.Node)

For Each Node In Treeview.Nodes

If Node.Parent = CheckedNode.Key Then
Node.Checked = CheckedNode.checked
End If

Next

End Sub

But this gives me an error saying : "Object Variable or blockvariable With not set" (I had to translate the error so maybe it could be slightly different in english)... I can't think of anything that is wrong in the code, and I can't find a codesnippet that tells me otherwise, so what is causing the error?

Treeview - How To Drag A Node Item To Another Node Group
I have a program that im making, which has a treeview control. Ive got everything finished BUT, i need to make it so that the user can grad a node from one group, to a different group, and have it actually be placed in the group where it is dropped. Think of it like your lnstant Messenger buddy list.

Buddies:
User1
User2
User3 <--
User5 <-- The user should be able to drop "User4" between there.
User6
Family:
User7
User8
User4 <-- The user needs to be able to drag and drop this node to the
User9 "Buddies" group above.

I hope that little diagram thing helped explain what im trying to achieve. Ive played around with this for a bit, but i just started working with the treeview control so im not very familiar with it, also, ive never done anything with a drag/drop effect before. However, ive looked around the forum and ive found how to drag a node to another item in the form, like a textbox or something.

I really need help with this and it would be realllly appreciated if someone could help me get it to work. Thanks.

Stop Item Dragging/moving In ListView
Is there any way you can stop the user from moving the item position in a listview?? I need them to stay the same as i added them first by code, with them being fixed for the user and not allowing any movement of item position!

thanks!

[VB6][TREEVIEW] How To Unchecked The Treeview Node
I would like to make a function for the user, when a user checked any of the parent node, the entire of child node and parent node will checked.
I tried to write on myself. The child node will checked if checked on parent node. However, i can't unchecked the child node if parent node unchecked.


Code:
Dim IndentifyCheck As Integer
Dim nodMP As Node
Dim nodP As Node
identifycheck = 0
If Node.Checked = True Then
If Not Node.Parent Is Nothing Then ' Parent exist.
Node.Parent.Checked = True
If Not Node.Parent.Parent Is Nothing Then
Node.Parent.Parent.Checked = True
End If

End If
If Not Node.Child Is Nothing Then
Set nodMP = Node.Child
Do Until nodMP Is Nothing
nodMP.Checked = True
If Not nodMP Is Nothing Then
Set nodP = nodMP.Child
Do Until nodP Is Nothing
nodP.Checked = True
Set nodP = nodP.Next
Loop

End If
Set nodMP = nodMP.Next
Loop

End If
Else
Do Until Node = Node.LastSibling
If Node.Checked Then
identifycheck = identifycheck + 1
End If
Set Node = Node.Next
Loop
If identifycheck < 1 Then
If Not Node.Parent Is Nothing Then
Node.Parent.Checked = False
If Not Node.Parent.Parent Is Nothing Then
Node.Parent.Parent.Checked = False
End If
End If
End If
If Not Node.Child Is Nothing Then
Set nodMP = Node.Child
Do Until nodMP Is Nothing
nodMP.Checked = False
If Not nodMP Is Nothing Then
Set nodP = nodMP.Child
Do Until nodP Is Nothing
nodP.Checked = False
Set nodP = nodP.Next
Loop

End If
Set nodMP = nodMP.Next
Loop

End If

End If

Dragging And Dropping Outside Of A Treeview
I am attempting to create an application where a treeview has a hierarchal display of data, and the user can drag any item from the treeview to a textbox which is used to create a script.

My problem is this:

Say the root node is currently selected. When the user grabs an item which is not the root node, and drags it to the textbox, the root node is the only thing that gets moved.

If the user first clicks on the item (going through all mouse_down, mouse_up and node_click events) and then clicks and drags, it works fine.

But I'd like it so that the user doen't have to click twice (dragging with the second click) to drag an item outside of the treeview.

If the user drags the item around inside the treeview, the newly clicked node remains selected. But drag it out of the treeview and BAM! The originally selected node becomes selected again.

Any thoughts?

Thanks.

Dragging Items In A Treeview Between Itself
I've got a tree view control in my application and i need to drag its children nodes between the parent nodes. I.e you can be able to change the parent node just by dragging a node from one parent node to anotehr. Is this possible to be done by native VB, or does it need some API involveD?

I've seen several applications using this functionality. Any idea how i can solve this problem?

Thanks!

XML Node As Treeview Node/Tag
Hi.

I'm looking to store a reference to an xml node in the Tag of a tree view node.

I can't store the actual text etc because the i need the to be able to edit the xml sub nodes in place.

I'm thinking a can store the the memory address (via ObjPtr) as the treeview node tag, but does anyone know to do the reverse (i.e. get object from a given memory address) ?



td.

Dragging With The Treeview (not Very Hard, Honest)
i have a form with a treeview and listview that lets you drag items from the treeview to the listview. however, it should only let you drag child items from the treeview, so i have this code:


VB Code:
Private Sub tvwHeaders_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)    If (Button = vbLeftButton) Then        If (tvwHeaders.SelectedItem.Parent Is Nothing) Then Exit Sub                tvwHeaders.DragIcon = tvwHeaders.SelectedItem.CreateDragImage        tvwHeaders.Drag vbBeginDrag    End IfEnd Sub Private Sub lvwSubHeaders_DragDrop(Source As Control, x As Single, y As Single)    On Error GoTo ErrHandler        If (Source Is tvwHeaders) Then        lvwSubHeaders.ListItems.Add , Source.SelectedItem.Key, Source.SelectedItem.Text, 1    End If        Exit Sub    ErrHandler:    If (Err.Number = 35602) Then        MsgBox "You have already included this list.", vbInformation, "Cannot Add List"    End IfEnd Sub


if you click a child item, then click a parent item, release the mouse button, click again and drag, it won't let you move it (good). however, if you click a child item, release the mouse button, click a parent item (without releasing the mouse button) and drag, it'll drag the parent item (bad). if that makes any sense to you, is there any way i can prevent that?

Scroll The Treeview When Dragging And Dropping
The only information that I can find on scrolling a treeview when dragging and dropping a node is out on microsoft's support online - Article ID: Q177743

http://support.microsoft.com/suppor...s/q177/7/43.asp

The problem that I am having with is solution is that when the mouse button is released over an area other than the treeview area, it continues to scroll. It does not recognize that the mouse button has been released. It also continues to scroll is you drag it off the form, which microsoft applications do not do.

Does anyone have a fix for this or possibly a better solution?

Dragging Items In A Treeview In Itself (changing Locations)
I need to perform a drag-drop function on a treeview control in which the user can move items between different nodes of the tree.

I need to implement this functionality via dragand drop, so as to make it easy to interact. Is this possible? Do i need to go into detailed API or wiht native VB it is possible?

Any ideas? Thanks a lot ppl

Code To AutoScroll Treeview When Dragging And Dropping
Hi Guys,

I need code to autoscroll my treeview whenever I drag and drop an item. Please help me.

Treeview: Dragging And DoubleClicking (harder Then It Sounds)
Hello,

I got a little problem wih my treeview. I want the user to be able to Drag some items and double click on some items. They both work,but the only problem is when you doubleclick on an item (should be quite fast and it doesn't always happens) then it look likes you want to drag what is quite annoying.

Is there anyone who could fix this??

Thanx in advance

Dragging A Record In Datagrid Into TreeView Control
Dear All
is it possible for us Drag a record and then drop into a Treeview control on the same screen ? If yes,,,HOW

Urgent ! Pls Help

TIA

regard
Jason

Capturing Node In Case Of Moving By Key_down
Hi Gurus!
Let me ask you a question.
In TreeView, It is possible to move between nodes.
Then, Can I get the node in TreeView's KeyDown event(,KeyPress or KeyUp )?
In other words, I'd like to know current focused node after moving between each nodes.
Could anybody let me know?

DonYoung,Jeong

Open Node && Close Already Open Node In TreeView!
Suppose my TreeView looks like this:


Code:
Asia
|_____India
|_____Mumbai

|_____Pakistan
|_____Karachi

|_____Japan
|_____Tokyo

|_____China
|_____Beijing


Assume that all the nodes are closed. I open India; Mumbai can be seen. Keeping India open, I then open Japan; Tokyo can be seen. What I want is when I open Japan, India which was already open should get closed i.e. at any time, only 1 node should remain open. How do I do this?

Adding A Child Node To A Child Node In A TreeView
Does any one know what the Syntext "Coding" is to

add a child to a child node

In a TreeView ?



Edited by - Malan on 7/1/2004 2:25:03 PM

TreeVIew Node Id
i would like to give an id to my node I tried keys and tag without any sucess.
I want to identify them so i can sort them (I want to know who is Parent and who is child) anyone go an idea?!

Getting First And Last Node In The Treeview
how can i get the first item (that appears to be first) or the last item in the treeview?

TreeView.Nodes(1) does not work, or treeview.nodes(treeview.nodes.count).

Because if i enter a node before 1, by doing Add and making it a tvwprvious relationship to it, the "first" node will still have index of 1, and the "new" node will not have 1!

how can it be done?

thanks!

Treeview Node
Hi
I have a treeview inside my form.Upon clicking on a node,I want to display the text of this node in a label
How can I do it?

Get TreeView Node Key
I have a TreeView and a form that populates a ComboBox depending on nodes in the TreeView. Well, I would like to be able to add a node the the TreeView in a certain spot via selecting an item from the ComboBox. What I need to be able to do is get a node's key by knowing it's text? Make sense? Thanks, Jeremy

TreeView Node Help
I'm adding a parent node to a treeview and then adding others, but I want to make sure that the first parent node added will stay last in the tree. How can I accomplish this?

TreeView Last Node
Would appreciate some help in how to quickly find the last node in a treeview so it can be expanded. The user adds a record and when it is added to the treeview I want it expanded so the user can verify it's contents before proceeding to the next record.

Is there some way I can loop through the nodes to determine which is the last one.

Thanks in advance all.

-=Bryan=-

Treeview Node Focus
I got a treeview control on the left side of a form that when a node is clicked it populates the right side with detailed information. If a user changes the detailed info on the right I set a flag to indicate that data has been changed. If the user then clicks on another node I popup a message box asking them to save or cancel the current record. What I want to do is if the user selects cancel I want to stay focused on the current node and not the new node they just clicked. I tried using the MouseUp event and the NodeClick event to no avail. Both change the focus to the newly clicked node even after I reset selection to the node I want. Any help would be appreciated.

Treeview Node Is Editable
Hi,

I want to make node text not editable.

please help me

Hiding Node(s) In A TreeView
Hello

I search for a way to hide special node(s) in a treeview
Is it possible ?

or would I be obliged to delete these special nodes...

Thanks

Treeview Node Visible
i'm doing two things - creating a sub folder & a child node.
routine almost works - i can not get the newly created node to become visible - i have to exit routine & reenter it and then it is visible. here is code:

Private Sub cmdCreateNewFolder_Click()
Dim wnode As Node
If txtFolder.Text <> "" Then
If (gFSO.FolderExists(gDefaultTreePath & "" & Trim(txtFolder.Text))) Then
Call MsgBox_GenWarning("Folder Exist", "Creating New Folder")
txtFolder.Text = ""
Exit Sub
End If
gFSO.CreateFolder (gDefaultTreePath & "" & Trim(txtFolder.Text))
''METHOD 1
TreeView1.Nodes.Add gDefaultTreePath, tvwChild, gDefaultTreePath & "" & Trim(txtFolder.Text)
DoEvents
TreeView1.Nodes(gDefaultTreePath & "" & Trim(txtFolder.Text)).EnsureVisible
''=========
''METHOD 2
''Set wnode = TreeView1.Nodes.Add(gDefaultTreePath, tvwChild, gDefaultTreePath & "" & Trim(txtFolder.Text))
''DoEvents
''wnode.EnsureVisible

txtFolder.Text = ""
End If
End Sub



i've include the two methods i have tried & neither works.
so can someone tell what is wrong. thanks

otom

TreeView Add Node Problem
Hi,

how can I check whether a node with a defined key does already exist before I create them with?


Code:
Set Add_TreeSection = fMainForm.tvwVariables.Nodes.Add(, , pSECTION, pSECTION)
In case the node was already added I could add a new child node directly without adding the parent node.

thanks
Stefan

Treeview - Collapse A Node
I have a treeview on which Node ("Root16") expands to 6 child nodes.
Each child node prints out a different report from excel.

What I need is for the Node to collapse and abort the print-out to excel if certain criteria is not met - leaving the menu form visible.

The code for ascertaining that the criteria is met is a Function in a module.

I understand that this is part of the code -

HTML Code:
frmMenu.TreeView1.SelectedItem.Expanded = False
I need to know where to state the "Root 16" which is to be collapsed in the code?

Any help would be appreciated.

Treeview Node Question
Hi,

For my project I use a Treeview and I was wondering how I get all nodes to be visible no matter how they relate to each other (child, ..).
The nodes are created with a recursive subroutine.

Also, is this possible? (in pseudo code)

Dim Root

Set Root = Tree.Nodes("root")
Tree.Nodes.Clear
Set Tree.Nodes("Root") = Root

I need something like this to show different kinds of information in the same treeview-window on my form. (so I store the info in a node and when the user presses a button I show the right node)

Thank you!

OsMo

Right Clicking A TreeView Node
I'd like to add the ability of someone to right click a node in my treeview and delete it from the tree. I have looked online to find examples of this and tried them but I keep having a problem with HitTest. Can someone help me out? Thanks, Jeremy

TreeView Node Problem
Is there a way to keep a child node from having the same text as a parent node? Also, is it possible to make it where two or more nodes under the same parent can't have the same text? Thanks, Jeremy

Right Clicking Node In Treeview
How can I detect when the user has right clicked ON A NODE. I can detect when there is right click anywhere, or a left clcik on a node but not both. Thanks

Deleting Node In Treeview
How must i delete a selected node in a treeview (with a commandbutton)???

Treeview Node Index
How do I return the index of the node I just added. I'm building a treeview that is populated with items from a hiearchy. I'm pulling the parents from one table and children from another. How do I know what node(?) the children go with.

rs.open "Select * from table1",cn,adopenkeyset,adlockoptimistic

do while rs.eof = false

TV.Nodes.Add , , , rs!field1 'What is the node index?

if rs2.state = 1 then rs2.close
s$ = "Select * from table2 where field1 like '"
s$ = s$ & " rs!field1" & "'"
rs2.open s$,cn,adopenkeyset,adlockoptimistic

do while rs2.eof = false
Set g_node = TV.Nodes.Add(?, tvwChild, , rs2.field2)
g_node.EnsureVisible
rs2.movenext
loop
rs.movenext
loop

Copying A Node From One TreeView To Another
Hi,

I have a form which contains two TreeViews. If the user selects a node in the first one, how do I copy this node (and all it's eventual children, and there children) to the second TreeView?

I hope somebody can help me out...

Regards,

Capo-Jer

TreeView Node Limits
Dear All,


I've looked until I'm cross-eyed, but still can't tell if there is a maximum node count or other memory limitations for the TreeView control.

Can anyone advise, please.


Many thanks,
Paul.

Getting Parent Node In Treeview
hi,
I want to get the parent node of an item in a treeview when the user selects it. If the node selected is a parent node, then i dont want a crash.... i am currently using the following

set curnode = treeview1.hitttest(x,y)

if not curnode is nothing then
debug.print currnode.parent.text


this does not work... can anybody help?

TreeView Node Text Other App.
trying to retrieve nodes' text in a tree view object from a different application. I have manage to get the window handle of the object but do not know how to get the data in the tree view, class found is systreeview32.

Sending TreeView message using these functions and variables

Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
wParam As Any, _
lParam As Any) As Long ' <---

' ====================================================================== =====
' treeview definitions defined in Commctrl.h at:
' http://premium.microsoft.com/msdn/li...c/c67_4c8m.htm

Public Type TVITEM ' was TV_ITEM
mask As Long
hItem As Long
State As Long
stateMask As Long
pszText As String ' Long ' pointer
cchTextMax As Long
iImage As Long
iSelectedImage As Long
cChildren As Long
lParam As Long
End Type

Public Enum TVITEM_mask
TVIF_TEXT = &H1
TVIF_IMAGE = &H2
TVIF_PARAM = &H4
TVIF_STATE = &H8
TVIF_HANDLE = &H10
TVIF_SELECTEDIMAGE = &H20
TVIF_CHILDREN = &H40
#If (WIN32_IE >= &H400) Then ' WIN32_IE = 1024 (>= Comctl32.dll v4.71)
TVIF_INTEGRAL = &H80
#End If
TVIF_DI_SETITEM = &H1000 ' Notification
End Enum

' User-defined as the maximum treeview item text length.
' If an items text exceeds this value when calling GetTVItemText
' there could be problems...
Public Const MAX_ITEM = 256

' messages
Public Const TV_FIRST = &H1100
Public Const TVM_GETNEXTITEM = (TV_FIRST + 10)
Public Const TVM_GETITEM = (TV_FIRST + 12)

' TVM_GETNEXTITEM wParam values
Public Enum TVGN_Flags
TVGN_ROOT = &H0
TVGN_NEXT = &H1
TVGN_PREVIOUS = &H2
TVGN_PARENT = &H3
TVGN_CHILD = &H4
TVGN_FIRSTVISIBLE = &H5
TVGN_NEXTVISIBLE = &H6
TVGN_PREVIOUSVISIBLE = &H7
TVGN_DROPHILITE = &H8
TVGN_CARET = &H9
#If (WIN32_IE >= &H400) Then ' >= Comctl32.dll v4.71
TVGN_LASTVISIBLE = &HA
#End If
End Enum

This return the handle of TreeView
nLong= SendMessage(hWnd, TVM_GETNEXTITEM, TVGN_ROOT,
0&)

But the text is not return using
Dim tvi As TVITEM

' Initialize the struct to retrieve the item's text.
tvi.mask = TVIF_TEXT
tvi.hItem = hItem
tvi.pszText = String$(260, 0)
tvi.cchTextMax = 260
nChild = SendMessage(hWnd, TVM_GETITEM, 0, tvi)

but the tvi.pszText is always empty...

I want the name from which person is logon in the Yahoo Messenger window, that is found in treeview root node.

Any ideas

Treeview Node At Startup
I have done a search, and it's probably here somewhere, but ..

How do I set which node has the focus in a treeview at startup?

Thanks

Right-Click TreeView Node!
A TreeView looks like this:

Code:
Asia
|____China
|____India
|____Japan

Europe
|____France
|____Germany
|____Sweden

South America
|____Argentina
|____Brazil
|____Paraguay

Australia
|___No countries
If any parent node (i.e. the continents) is right-clicked & the parent node is in a collapsed state, a menu pops-up with 2 items - Delete & Expand. On the other hand, if the parent node is in the expanded state, the popup menu shows 2 items - Delete & Collapse.

Users can even delete the nodes - be it a parent node or a child node. If a parent node doesn't have any children (i.e. any country), expanding that parent node shows only 1 child node whose text is No countries.

What I want is if a parent node has no children i.e. it doesn't have any country name as a child & consequently has only the No countries node, then the Delete menu item when the No countries node is right-clicked should be disabled but the Delete menu item should remain enabled when the parent node (i.e. Australia in the TreeView shown above) is right-clicked. This is what I tried:
VB Code:
Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)    Dim objNode As Node     Set objNode = TreeView1.HitTest(X, Y)    If (Button = vbRightButton) Then        If Not (objNode Is Nothing) Then            If (objNode.Child.Text = "No countries") Then                mnuDelete.Enabled = False            End If        End If    End IfEnd Sub
When the No countries node is right-clicked, VB generates the Object variable or With block variable not set error. Even the Delete menu item remains disabled when Australia is right-clicked whereas I want it to be enabled.

What am I missing in the above code?

Edit TreeView Node!
In a TreeView, users can edit the nodes in the TreeView. Each of the nodes are also accompanied by an image. When a node gets selected, it's image changes.

Now what I find is when a node is in the edit mode, some part of the image gets hidden as shown in the 2nd image shown below (a part of the green star is concealed; the 1st image is how the TreeView looks when it is in the non-editable state).

How do I prevent this concealed part of the image from getting obscured when a node is in the edit mode?

Note that all the nodes are in the same level (no parent nodes or child nodes); so changing the indentation doesn't make any difference.

Copyright © 2005-08 www.BigResource.com, All rights reserved