WinForms: Alternative to SplitContainer?

前端 未结 5 963
小蘑菇
小蘑菇 2021-01-12 19:51

Are there any alternative controls someone can suggest to replace the WinForms SplitContainer? I don\'t like how the SplitContainer shows that weird, dotted strip when its s

5条回答
  •  生来不讨喜
    2021-01-12 20:43

    You can't tinker with SplitContainer at all. One possibility is to eliminate it entirely if you are only using it to resize a control. You could use mouse events on the control itself instead. Drop a TreeView on a form and dock it on the left. Subscribe to the MouseDown/Move/Up events and write something like this:

        bool mDragging;
    
        private bool onTreeEdge(Point pos) {
            return pos.X >= treeView1.DisplayRectangle.Right - 3;
        }
        private void treeView1_MouseMove(object sender, MouseEventArgs e) {
            treeView1.Cursor = mDragging || onTreeEdge(e.Location) ? Cursors.VSplit : Cursors.Default;
            if (mDragging) treeView1.Width = e.X;
        }
        private void treeView1_MouseDown(object sender, MouseEventArgs e) {
            mDragging = onTreeEdge(e.Location);
            if (mDragging) treeView1.Capture = true;
        }
        private void treeView1_MouseUp(object sender, MouseEventArgs e) {
            mDragging = false;
        }
    

提交回复
热议问题