|
-
Dec 14th, 2003, 12:42 PM
#1
Thread Starter
Member
Single click select issue in treeview
I am having trouble with selecting items in a treeview using single clicks. WhenI ue the double click even it works fine, but when using single clicks the result is always 1 step behind (it's hard to explain this, but I'l try):
have these items in a treeview:
70s
80s
90s
00s
Current
When I first come to the treeview and select say 90s, instead 70s (the first node) is selected and it's link shown in the listview, if I then click 80s, the 90s contents are shown and so on.. I use this to get the node:
Dim flpath As String = trvRedCase.SelectedNode.FullPath.ToString
which works fine with doubleclick, but has the above result with single clicks..
Anyone got any ideas..???
I'll just post the whole sub to show you what I am doing:
Code:
Private Sub trvRedCase_GetNode(ByVal sender As Object, ByVal _
e As System.EventArgs) Handles trvRedCase.Click
Dim Splash As New frmSplash
Splash.splsStatus.Text = "Loading and sorting (sub)Group"
Splash.splsStatus.Refresh()
Splash.Show()
Dim flpath As String = trvRedCase.SelectedNode.FullPath.ToString
If flpath = trvRedCase.SelectedNode.ToString.Remove(0, 10) Then
flgrp = 1
section = flpath
Else
flgrp = 0
section = flpath.Remove(0, flpath.LastIndexOf("\") + 1)
flpath = flpath.Substring(0, flpath.LastIndexOf("\"))
End If
Call FillRedCase(flpath, section)
Splash.Hide()
End Sub
Last edited by paulheu; Dec 15th, 2003 at 06:06 AM.
-
Dec 15th, 2003, 06:07 AM
#2
Thread Starter
Member
-
Dec 15th, 2003, 06:36 AM
#3
What code have you got in the NodeClick event?
I don't live here any more.
-
Dec 15th, 2003, 09:35 AM
#4
Hyperactive Member
We use treeview as well, but place the code in the Afterselect event and seem to have no problems at all.
Wealso use a custime treenoode with extra properties, so I hhave uncluded that here as wel:
Public Class TfrNode
Inherits TreeNode
Public Name As String
Public Landlord As Integer
Public Proprty As Integer
Public Unit As Integer
Public Tenancy As Integer
Sub New(ByVal Desc As String, ByVal Landlord1 As Integer, ByVal Proprty1 As Integer, ByVal Unit1 As Integer, ByVal Tenancy1 As Integer)
MyBase.New()
Name = Desc
Landlord = Landlord1
Proprty = Proprty1
Unit = Unit1
Tenancy = Tenancy1
Me.Text = Name
End Sub
End Class
Public MyNode As TfrNode
Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
MyNode = CType(e.Node, TfrNode)
idx = e.Node.Index
ThisLandlord = MyNode.Landlord
ThisProp = MyNode.Proprty
ThisUnit = MyNode.Unit
ThisTenancy = MyNode.Tenancy
End Sub
-
Dec 15th, 2003, 10:30 AM
#5
Thread Starter
Member
Well switching to after select worked, and I also found a bug elsewhere which made it appear as-if it didnot work..
Another small issue is that sometime a treenode will blank during sortingin the listview and sometimes it won't.. (I'd prefer it wouldn't) Any ideas on a possible solution for that?
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
|