Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 916977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:08:09+00:00 2026-05-15T18:08:09+00:00

I am creating a user control where when a user clicks a button a

  • 0

I am creating a user control where when a user clicks a button a popup window will show up with information. The popup window is driven by a toolStripDropDown so when it shows up it does 2 things

  1. Does not move the other controls on the form around but displays over them
  2. That it can show the details outside the bounds of the user control itself without having to reserve the space ahead of time

Here is some code

Public Class Popup
Private treeViewHost As ToolStripControlHost
Private Shadows dropDown As ToolStripDropDown

Public Sub New()
    InitializeComponent()
    Dim treeView As New TreeView()

    treeView.BorderStyle = BorderStyle.None
    treeViewHost = New ToolStripControlHost(treeView)
    treeViewHost.Padding = New Padding(6)

    dropDown = New ToolStripDropDown()
    dropDown.AutoClose = False
    dropDown.AutoSize = True
    dropDown.BackColor = Color.LemonChiffon
    dropDown.Items.Add(treeViewHost)
End Sub

Public Sub ShowDropDown()      
    If dropDown.Visible = False Then
        dropDown.Show(Me, Button1.Left + Button1.Height + 5, Button1.Top)
    Else
        dropDown.Close()
    End If

End Sub    

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ShowDropDown()
End Sub

Private Sub Popup_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move, Button1.Move
    If (dropDown IsNot Nothing AndAlso Button1 IsNot Nothing AndAlso dropDown.Visible) Then
        dropDown.Left = Button1.Left + Button1.Height + 5
        dropDown.Top = Button1.Top
    End If
End Sub
End Class

And here is the init of the control

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.  
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
    Me.Button1 = New System.Windows.Forms.Button
    Me.SuspendLayout()
    '
    'Button1
    '
    Me.Button1.Location = New System.Drawing.Point(4, 4)
    Me.Button1.Name = "Button1"
    Me.Button1.Size = New System.Drawing.Size(27, 23)
    Me.Button1.TabIndex = 0
    Me.Button1.Text = "Button1"
    Me.Button1.UseVisualStyleBackColor = True
    '
    'Popup
    '
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    Me.Controls.Add(Me.Button1)
    Me.Name = "Popup"
    Me.Size = New System.Drawing.Size(39, 35)
    Me.ResumeLayout(False)

End Sub
Friend WithEvents Button1 As System.Windows.Forms.Button

Now my issue is as the form moves or resizes the Tooldropdown does not move relative. I understand that. When I try to capture the move event of the user control that event does not fire when the entire form moves. There has to be something I can capture because the controls in the container of the form move relative, what drives that? I tried wndproc but nothing fires during form move unless the form is repainted.

Thank you

Current code is in VB but I can handle both.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:08:10+00:00Added an answer on May 15, 2026 at 6:08 pm

    I think this did it

     AddHandler Me.ParentForm.Move, AddressOf Popup_Move
    

    In the load event. I had to do it in the load event because ParentForm is not available earlier. I also tried the ParentChange event but that did not work if I was in a Panel

    Me.Parent would equal Panel but
    Me.Parent.Parent would equal nothing (also .ParentForm was Nothing)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given that you're creating a User Control in WPF that will be displayed on
Hi I'm creating test application that has a user control with a Button that
I am creating a Windows forms user control. This control has a textbox and
I have a user control called HomePage.xaml . I'm creating a model instance (using
I am creating a custom server control to generate button elements with specific markup
So I'm creating a custom user control in .NET 2.0 and this user control
I am dynamically creating the columns for a data grid in a User control
I am creating a user control where in i have different HTML text boxes
Is there some kind of tool for creating user interfaces using ATL for C/C++?
I'm creating a User Interface using PyQt4 module . the problem i'am facing is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.