你可以通过DOCK=FILL的方式来调整,把它放到PANDEL中这样可以保证其它控件的位置,否则,界面就乱了
群:6831395

解决方案 »

  1.   

    可以的.但你最好从TreeView自己来继承一个类,然后在里面添加类似如下的代码就行了:
    private const int WM_NCHITTEST = 0x84;
    private const int HTCLIENT = 0x1;
    private const int HTSIZE = 0x4;
    private const int HTCAPTION = 0x2; 
    private const int WM_SIZING = 532;
    private const int HTMINBUTTON = 8;private const int BorderWidth = 5;
    //可以调整窗体的大小和移动窗体的位置
    protected override void WndProc(ref Message m)
    {
    switch(m.Msg)
    {
    case WM_NCHITTEST:
    base.WndProc(ref m);
    if (DesignMode)
    {
    return;
    } if ((int)m.Result == HTCLIENT)
    if ((Cursor.Position.X<=this.Left + BorderWidth) && (Cursor.Position.Y <= this.Top + BorderWidth))
    m.Result = (IntPtr)13;//左上
    else if ((Cursor.Position.X>=this.Left + this.Width-BorderWidth) && (Cursor.Position.Y<=this.Top +BorderWidth))
    m.Result = (IntPtr)14;//右上
    else if ((Cursor.Position.X <= this.Left + BorderWidth) && (Cursor.Position.Y>=this.Top + this.Height-BorderWidth))
    m.Result = (IntPtr)16;//左下
    else if ((Cursor.Position.X>=this.Left + this.Width-BorderWidth) && (Cursor.Position.Y>=this.Top + this.Height-BorderWidth))
    m.Result = (IntPtr)17;//右下
    else if (Cursor.Position.X<=this.Left + BorderWidth)
    m.Result = (IntPtr)10;//左
    else if (Cursor.Position.X>=this.Left + this.Width-BorderWidth)
    m.Result = (IntPtr)11;//右
    else if (Cursor.Position.Y<=this.Top + BorderWidth)
    m.Result = (IntPtr)12;//上
    else if (Cursor.Position.Y>=this.Top + this.Height-BorderWidth)
    m.Result = (IntPtr)15;//下
    else 
    m.Result = (IntPtr)HTCAPTION;//移动窗体
    return;
    default:
    base.WndProc(ref m);
    break;
    }

    }