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
568 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now