Declined
Last Updated: 16 Feb 2024 19:56 by ADMIN
Abhiramy
Created on: 13 Aug 2020 11:13
Category: UI for WinForms
Type: Bug Report
2
Event not fired properly when Treeview is converted to RadTreeView

I have a form which contains TreeView control. I need to convert it to RadTreeView. So I replaced TreeView control with RadTreeView and TreeNode with RadTreeNode in the code. I found that the events in both are different, so tried to replace the events with similar events in RadTree.

Following are the events that I have replaced in my code :

1.  

        Private Sub TreeView1_AfterExpand(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvMain.AfterExpand

Replaced by -

        Private Sub TreeView1_AfterExpand(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RadTreeViewEventArgs) Handles tvMain.NodeExpandedChanged   

2.

            Private Sub TreeView1_AfterCollapse(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvMain.AfterCollapse

  Replaced by -  

            Private Sub TreeView1_AfterCollapse(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RadTreeViewEventArgs) Handles tvMain.NodeExpandedChanged

and included Expanded flag to check if it is expand or collapse.

Here, I noticed unwanted firing of this replaced event when compared to the old event, but I handled it using the Expanded flag.

3.

        Private Sub tvMain_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvMain.AfterSelect

Replaced by -

        Private Sub tvMain_AfterSelect(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.RadTreeViewEventArgs) Handles tvMain.SelectedNodesChanged

This event gets fired twice while clicking on a node.

My main issues are,

  • During the initial load of the form, the tree gets populated and at that time the select event (mentioned in point 3) fires automatically in my old project in which TreeView is used. But in the new project, during the load of the form the replaced event is not fired.
  • Similarly, when I clicks a node , the replaced select event fires twice. After that I have a button in the same form which works like, when we click on a node and then click on the add button it will add a new node to the tree under the selected node. Now the functionality of the button doesnt work because, within the click function of add button, treeView1.selectedNode is 'Nothing'. Eventhough the select event is fired on clicking the node, the selectednode is 'Nothing' inside the click function of add button.
2 comments
ADMIN
Dinko | Tech Support Engineer
Posted on: 16 Feb 2024 19:56

Hello Nadya,

The feedback item status is changed to Declined due to inactivity.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

ADMIN
Nadya | Tech Support Engineer
Posted on: 18 Aug 2020 14:56

Hello, Abhiramy,

Thank you for the provided information.

RadTreeView offers SelectedNodeChanged and SelectedNodesChanged events:

  • SelectedNodeChanged occurs after a tree node is selected, and is an alternative to AfterSelect in MS TreeView.
  • SelectedNodesChanged is similar to the SelectedNodeChanged event, which occurs when SelectedNoded collection has been changed.

In order to test the above-described behavior, I created a test project with RadTreeView and TreeView controls and subscribe to the AfterSelect and SelectedNodesChanged events. After the initial load of the form, none of the events get fired. Both events fire when the user selects a node. Could you make sure if you set programmatically the selected node in your code?

The SelectedNodesChanged fires when a node from RadTreeView, then fires the SelectedNodeChanged event. Thus, you can get the selected node through  RadTreeView1.SelectedNode that shows the last selected node. Please refer to the attached gif file. 

I attached my test project for your reference. If you are experiencing further difficulties I would kindly ask you to modify the project in a way to replicate the issue that you are facing.

I hope this helps. Let me know if you have other questions.

Regards,
Nadya
Progress Telerik