Show UserControl in Popoup

后端 未结 1 859
别跟我提以往
别跟我提以往 2021-01-25 05:09

I have a button and another control placed in a usercontrol I want to pop out the control below the button to the topp of all other controls when the bitton in the usercontrol i

相关标签:
1条回答
  • 2021-01-25 05:48

    You can host any kind of Control in a ToolStripControlHost and then add it to items of ToolStripDropDown and then show the dropdown:

    Dim dropdown As ToolStripDropDown = New ToolStripDropDown()
    Dim c As UserControl1 = New UserControl1()
    Dim host As ToolStripControlHost = New ToolStripControlHost(c)
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles Button2.Click
        If (dropdown.Items.Count = 0) Then
            host.BackColor = Color.White
            host.Margin = New Padding(2)
            c.MinimumSize = New Size(120, 100)
            dropdown.Padding = New Padding(0)
            dropdown.Margin = New Padding(0)
            dropdown.Items.Add(host)
        End If
        dropdown.Show(Button2, 0, Button1.Height)
    End Sub
    

    DropDown

    0 讨论(0)
提交回复
热议问题