treenode location

Posted on 2009-04-24
Last Modified: 2013-12-17
I want to show a form of border style none, under a treenode. I can not place it properly. If I collect e.Location the form is opening at wrong place if i drag the mouse just before the form show event. any suggestion?
Question by:Amitava_Mukherjee
    LVL 85

    Accepted Solution

    How about something like this?
    Public Class Form1
        Private Sub TreeView1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown
            If e.Button = Windows.Forms.MouseButtons.Right Then
                Dim tn As TreeNode = TreeView1.GetNodeAt(e.X, e.Y)
                If Not IsNothing(tn) Then
                    Dim rc As Rectangle = TreeView1.RectangleToScreen(tn.Bounds)
                    Dim f2 As New Form2
                    f2.StartPosition = FormStartPosition.Manual
                    f2.Location = New Point(rc.X, rc.Bottom)
                End If
            End If
        End Sub
    End Class

    Open in new window


    Author Closing Comment

    Perfect Solution, Thanx

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    728 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

    16 Experts available now in Live!

    Get 1:1 Help Now