如何使一个浮动控制 [英] How to make a floating control

查看:167
本文介绍了如何使一个浮动控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建的花车(潜在的),它的边界之外是一个包含表单控件。这可能吗?我怎么可以这样做呢?

I would like to create a control the floats (potentially) outside the bounds of it's containing form. Is this possible? How may I do it?

这功能很像上下文菜单的唯一我需要能够将其他控件添加到它,例如按钮和图像。

This would function much like Context Menu's only I need to be able to add other controls to it such as buttons and images.

推荐答案

您想做的事情窗体的FormBorderStyle设置为无,如果你想让它表现得像一个上下文菜单,那么你就需要配合显示给适当的在主窗体的事件处理程序。简单的例子,从鼠标点击事件处理程序设置的位置,并呼吁展示如下:

You want a Form with it's FormBorderStyle set to None, if you want it to behave like a context menu then you'll need to tie showing it to the appropriate event handler in your main form. Simple example below of setting the location and calling show from a mouse click event handler.

MyForm form = new MyForm();
form.Location = PointToScreen(new Point(e.X, e.Y));
form.Show();

这篇关于如何使一个浮动控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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