|
-
Apr 5th, 2003, 07:16 AM
#1
Thread Starter
Lively Member
NodeClick is killing me
Hi
I am working with Listview and I can call the record from Listview into textbox
But the Treeview ?????
I am traing to use this to call data from database when I click on the treeview but when I click on the top record I get data from database, I only want to get data when I select the Child
But I only get the 1 data in database if I click on somthing
Call DisplayItem(Node)
Private Sub DisplayItem(ByVal nodDisplayedNode As Node)
Dim rsDisplay As ADODB.Recordset
Set rsDisplay = New ADODB.Recordset
strSQL = "Select * from Produto"
rsDisplay.Open strSQL, cnn, adOpenStatic, adLockOptimistic
Nafn.Text = IIf(IsNull(rsDisplay.Fields("COD_GRUPO")) = True, "", rsDisplay.Fields("COD_GRUPO"))
End Sub
-----TREEVIEW-----------------------
This is the sample I am use to call data from database
Dim TotalProd As Long
Dim db As Database
Dim rs As Recordset
Dim dbProdutos As Recordset
Set db = OpenDatabase(App.Path + "\2000.mdb")
Screen.MousePointer = 11
DoEvents
Set dbGrupoProduto = db.OpenRecordset("SELECT * FROM Grupo_Produto ORDER BY NOME_GRUPO", dbOpenSnapshot)
With TreProdutos
Do Until dbGrupoProduto.EOF
Set dbProdutos = db.OpenRecordset("SELECT COD_PRO FROM Produto WHERE GRUPO_PRO = " & dbGrupoProduto!COD_GRUPO & " ORDER BY DES_PRO", dbOpenSnapshot)
If dbProdutos.RecordCount > 0 Then dbProdutos.MoveLast: dbProdutos.MoveFirst
.Nodes.Add , , , dbGrupoProduto!NOME_GRUPO & " - (" & dbProdutos.RecordCount & " )", 1
X = .Nodes.Count
Do Until dbProdutos.EOF
.Nodes.Add X, tvwChild, , "[ " & dbProdutos!COD_PRO & " ]", 2
TotalProd = TotalProd + 1
dbProdutos.MoveNext
Loop
dbGrupoProduto.MoveNext
Loop
End With
Set dbGrupoProduto = Nothing
Set dbProdutos = Nothing
DoEvents
Screen.MousePointer = 0
-
Apr 7th, 2003, 07:10 AM
#2
Addicted Member
hello,
Fiirst of all I think you will have to test if you're clicking a child or not. The way I do it is to set a mark when it's a child.
for example
Code:
Set treenode = TV.Nodes.Add("Root" & i, tvwChild, "longtext" & childcount, !maktx)
If you set "child" of something before the name of the node you'll be able to test on it whenever someone clicks the treeview. In the example I set "longtext" before the actual name so I can test where the user clicked.
I'm sure there are other ways too but this works fine for me.
-
Apr 7th, 2003, 04:00 PM
#3
Fanatic Member
You could do an if/then statement basically doing this:
VB Code:
Private Sub TreeView_NodeClick(ByVal CurNodeRun As Node)
If CurNodeRun.Parent Is Nothing THen
'Do not run query
Else
'Run Query
End If
End Sub
Something like that? Let me know, Jeremy
He who listens well, speaks well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|