在Popoup中显示UserControl [英] Show UserControl in Popoup

查看:35
本文介绍了在Popoup中显示UserControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在用户控件中放置了一个按钮和另一个控件单击用户控件中的Bitton时,我想弹出所有其他控件顶部按钮下方的控件

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 is clicked

推荐答案

您可以在 ToolStripDropDown ,然后显示下拉列表:

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

这篇关于在Popoup中显示UserControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆