Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a floating control

Tags:

c#

.net

winforms

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.

like image 274
Malfist Avatar asked Dec 08 '10 17:12

Malfist


1 Answers

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();
like image 198
Alex B Avatar answered Sep 20 '22 00:09

Alex B