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
584 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 86

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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