简体   繁体   中英

Resizing a panel in C#, Windows Forms

如何使用户在运行时通过拖动角落来调整面板大小?

我不知道要拖动角,但是您可以停靠面板并使用拆分器为用户提供一个用于调整停靠区域大小的位置。

You could intercept the mouse location and the click.. if it's in a corner then set a resizing boolean and then on the mousemove event you could implement something like this..

  if (_resizing)
  {
    this.Height = top + e.Y;
    this.Width = width + e.X;
  }

If you want to use an actual System.Windows.Forms.Panel and have it dynamically resize, then you will have to do it like if you were doing drag-n-drop. You will have to handle the mouse Click event on the panel, determine if you are on the edge of the panel (within a 2-3 pixels) and then handle the Drag events and change the Size property of the panel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM