Solved

Directory Treeview; How do I get "AfterSelect" on same node a second time when user reselects same node

Posted on 2004-09-01
5
575 Views
Last Modified: 2008-02-01
The order of activity when selecting a node is:

1. Click Event
2. After Select

I have an app that reuires the user to select an option for the folder before selecting the folder

so, the process is:

Select option
Select folder

the result is
1. click event
2. after select event

my app works on after select event, however if user makes wrong choice & I want to give a second chance without refreshing the whole directory tree, when the user re-selects the node, all I get is a click event

How do I refresh the node so I get the after select event the second time without refreshing the whole tree & the user having to trail through all the nodes again?
0
Comment
Question by:bemson
  • 2
  • 2
5 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11958613
One approach is to use the MouseDown event instead of the click or after select events:

    Private Sub TreeView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown
        Dim n As TreeNode = TreeView1.GetNodeAt(e.X, e.Y)
        If Not (n Is Nothing) Then
            ' do something with n...
        End If
    End Sub

Idle_Mind
0
 
LVL 10

Accepted Solution

by:
EBatista earned 125 total points
ID: 11959332
set the SelectedNodes property to nothing (or null for c#)

'vb
Treview1.SelectedNodes=nothing

//c#
Treview1.SelectedNodes=null;

regards
Elio
0
 

Author Comment

by:bemson
ID: 11961103
Thanks to Idle Mind & EBatista for your contributions

For Idle Mind:
Your solution appears to be the logical & technical answer & has some merit although using the mousedown event caused an error in the following code I had in the After Select event

The Code I had was: FolderName = e.Node.FullPath

Using the mouse event caused the e.Node.FullPath to generate an error as e is now not a part of System.Windows.Forms.TreeviewEventArgs

e is now a MouseEventArgs which does not give me the path

For EBatista:

A simple solution that resolves my problem, Thank you
0
 

Author Comment

by:bemson
ID: 11961114
Just a small point for EBatista

the code I used was Treview1.SelectedNode=nothing

no s on nodes

Thanks again
0
 
LVL 10

Expert Comment

by:EBatista
ID: 11961970
good
:)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question