Explorer control - "OnSelect" event?

6 posts, 1 answers
  1. Dracus
    Dracus avatar
    6 posts
    Member since:
    Jul 2006

    Posted 08 Sep 2019 Link to this post

    Hi team,

    is there any way to read what is selected (single or multi select) when I click on folder/file in Explorer control?
    Basically, I want to update my textbox with that what is selected.

    Thx,
    Oliver

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4004 posts

    Posted 09 Sep 2019 Link to this post

    Hello, Oliver,    

    Note that the ExlorerControl internally uses a RadTreeView for displaying the hierarchical structure of files/folders. It is displayed on the left side of the ExlorerControl. On the right, it uses a RadListView.

    In order to detect selection in both controls, feel free to use the following code snippet:

        
            public RadForm1()
            {
                InitializeComponent();
    
                this.explorerControl1.MainNavigationTreeView.SelectedNodeChanged += MainNavigationTreeView_SelectedNodeChanged;
                this.explorerControl1.FileBrowserListView.SelectedItemChanged += FileBrowserListView_SelectedItemChanged;
            }
    
            private void FileBrowserListView_SelectedItemChanged(object sender, EventArgs e)
            {
                if (this.explorerControl1.FileBrowserListView.SelectedItem != null)
                {
                    Console.WriteLine(this.explorerControl1.FileBrowserListView.SelectedItem.Text);
                }
            }
    
            private void MainNavigationTreeView_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)
            {
                Console.WriteLine("SelectedNode: " + e.Node.Text);
            }

    I hope this information helps. If you need any further assistance please don't hesitate to contact me.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Dracus
    Dracus avatar
    6 posts
    Member since:
    Jul 2006

    Posted 18 Dec 2019 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hi Dess,

    with huge delay thanks for update here.
    Btw. how can I do that from VB.NET?

    Thanks,
    Oliver

  4. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4004 posts

    Posted 19 Dec 2019 Link to this post

    Hello, Oliver,     

    Please refer to the below code snippet in VB.NET:
        Public Sub New()
            InitializeComponent()
            AddHandler Me.ExplorerControl1.MainNavigationTreeView.SelectedNodeChanged, AddressOf MainNavigationTreeView_SelectedNodeChanged
            AddHandler Me.ExplorerControl1.FileBrowserListView.SelectedItemChanged, AddressOf FileBrowserListView_SelectedItemChanged
        End Sub
    
        Private Sub FileBrowserListView_SelectedItemChanged(ByVal sender As Object, ByVal e As EventArgs)
            If Me.ExplorerControl1.FileBrowserListView.SelectedItem IsNot Nothing Then
                Console.WriteLine(Me.ExplorerControl1.FileBrowserListView.SelectedItem.Text)
            End If
        End Sub
    
        Private Sub MainNavigationTreeView_SelectedNodeChanged(ByVal sender As Object, ByVal e As RadTreeViewEventArgs)
            Console.WriteLine("SelectedNode: " & e.Node.Text)
        End Sub
    Feel free to use the free online Telerik Code Converter if you need to convert C# to VB.NET code and vice versa: http://converter.telerik.com/ 

    Should you have further questions please let me know.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. Dracus
    Dracus avatar
    6 posts
    Member since:
    Jul 2006

    Posted 19 Dec 2019 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thanks Dess. 

    Btw. convertors is providing:

    Public Sub New()

            InitializeComponent()
            Me.explorerControl1.MainNavigationTreeView.SelectedNodeChanged += AddressOf MainNavigationTreeView_SelectedNodeChanged
            Me.explorerControl1.FileBrowserListView.SelectedItemChanged += AddressOf FileBrowserListView_SelectedItemChanged
        End Sub

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4004 posts

    Posted 20 Dec 2019 Link to this post

    Hello, Oliver,     

    Indeed, the online converter may not provide absolutely correct VB.NET as the event subscriptions because it uses an external API for the conversion and we can't control the produced result. You may need to fix some small issues in order to build the code. However, the online converter can save you a lot of time when migrating a C# project or piece of code to VB.NET. Feel free to use it in future. 

    Should you have further questions please let me know.

     

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top