2
這是更多的方法問題。我知道如何創建一個可以從各個方面擴展的控件,但是我不明白爲什麼這個代碼在沒有重繪問題(抖動)的情況下不能流暢地工作。它僅從頂部縮放面板,但在此過程中抖動。我錯過了什麼?尺寸從上到下
public partial class Form1 : Form
{
Point MousePoint = new Point();
public Form1()
{
InitializeComponent();
panel1.MouseMove += Panel1_MouseMove;
panel1.MouseDown += Panel1_MouseDown;
panel1.Width = 100;
panel1.Height = 100;
}
private void Panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
MousePoint = e.Location;
}
}
private void Panel1_MouseMove(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
panel1.Top = e.Location.Y + panel1.Location.Y - MousePoint.Y;
panel1.Height = panel1.Height - e.Y + MousePoint.Y;
}
}
}
將窗體設置爲雙緩衝 – Aaron