C# Adding style to a control

前端 未结 2 1426
孤街浪徒
孤街浪徒 2021-01-11 17:21

I have a Panel and I am adding controls inside this panel. But there is a specific control that I would like to float. How would I go about doing that?

pnlOverheadD

2条回答
  •  隐瞒了意图╮
    2021-01-11 17:40

    IF you are talking about System.Windows.Forms here (and not WPF or ASP.NET):

    When you are talking about float, do you mean you want to position it anywhere you want by code? If so, just set the .Location property of the control.

    If you are talking about letting a control be moved around inside the panel by the user of your program, you will have to code that. That means capturing mouse events and moving the control accordingly?

    Alternatively you can instead of letting the control reside within the Panel, make it as a single control occupying a new form (hence you dont have to code all the mouse event handling). Just make sure that the window is limited to be moved within the boundaries of the "parent panel" (just check on the move event of the form if its within the boundariesm and force it to stay inside).

提交回复
热议问题