컨테이너 패널 크기를 넘어 스플리터로 분리 된 컨트롤 크기를 조정하는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com/questions/1817453

  •  08-07-2019
  •  | 
  •  

문제

스플리터로 분리 된 패널에 몇 가지 USERCONTROL이 있습니다. 함유 패널은 자동 스CROLL로 설정됩니다.

스플리터 컨트롤은 '스플릿'제어를 선별 할 때 부모의 크기를 고려하기 때문에 내부의 USERCONTROL의 크기 조정은 패널의 크기에 의해 제한됩니다.

사용자가 릴리스 할 때 마우스가 (컨테이너/양식의 범위를 넘어서도) 마우스가 어디에 있든 스플리터를 아래로 이동하고 컨테이너 패널에 그에 따라 크기를 조정하고 (필요한 경우 스크롤 바를 표시).

나는 다른 패널로 포장하고, Minsize 등으로 연주하는 모든 종류의 조합을 시도했습니다. 이것은 지금까지 내가 생각해 낸 최고이지만, 내가 원하는 것이 아닙니다.

alt text

아무도 아이디어가 있습니까?

도움이 되었습니까?

해결책

당신은 a를 설정할 수 있습니다 마우스 후크 마우스 버튼을 누르고 마우스 버튼이 해제되면 해제되면 해제됩니다. 훅 콜백에서 마우스 위치를보고 컨트롤을 적절하게 조정할 수 있습니다.

편집하다:

대신 부모 컨테이너의 오른쪽 하단에 스크롤 위치를 고정하기 위해 사용자가 드래그 할 수있는 특수 컨트롤을 사용할 수 있습니다. 사용자는 컨트롤을 드래그하여 영역을 더 크게 만들 수 있으며, 앵커 또는 도크 설정을 사용하지 않으면 컨트롤 크기를 수동으로 조정하여 부모 영역을 채울 수 있습니다.

나는 내가 한 프로젝트를 위해 잠시 동안 이와 같은 것을 구현했다. 나는 그것을 삼각형으로 만들었고 ToolStrip. 다음은 다음과 같습니다 ScrollHolder 제어:

public ScrollHolder()
{
    this.Size = new Size(21, 21);
    this.BackColor = SystemColors.Control;
}

protected override void OnPaint(PaintEventArgs e)
{
    Point bottomLeft = new Point(0, this.Height);
    Point topRight = new Point(this.Width, 0);
    Pen controlDark = SystemPens.ControlDark;
    Pen controlLightLight = SystemPens.ControlLightLight;
    Pen controlDark2Px = new Pen(SystemColors.ControlDark, 2);
    Point bottomRight = new Point(this.Width, this.Height);
    e.Graphics.DrawLine(
        controlLightLight, 
        bottomLeft.X, 
        bottomLeft.Y - 2, 
        bottomRight.X, 
        bottomRight.Y - 2);
    e.Graphics.DrawLine(controlDark, bottomLeft, topRight);
    e.Graphics.DrawLine(
        controlLightLight, 
        bottomLeft.X + 1, 
        bottomLeft.Y, 
        topRight.X, 
        topRight.Y + 1);
    e.Graphics.DrawLine(controlDark2Px, bottomLeft, bottomRight);
    e.Graphics.DrawLine(controlDark2Px, bottomRight, topRight);
    int xNumberOfGripDots = this.Width / 4;
    for (int x = 1; x < xNumberOfGripDots; x++)
    {
        for (int y = 1; y < 5 - x; y++)
        {
            DrawGripDot(e.Graphics, new Point(
                this.Width - (y * 4), this.Height - (x * 4) - 1));
        }
    }
}

private static void DrawGripDot(Graphics g, Point location)
{
    g.FillRectangle(
        SystemBrushes.ControlLightLight, location.X + 1, location.Y + 1, 2, 2);
    g.FillRectangle(SystemBrushes.ControlDark, location.X, location.Y, 2, 2);
}

protected override void OnResize(EventArgs e)
{
    this.SetRegion();
    base.OnResize(e);
}

private void SetRegion()
{
    GraphicsPath path = new GraphicsPath();
    path.AddPolygon(new Point[] 
    { 
        new Point(this.Width, 0), 
        new Point(this.Width, this.Height),
        new Point(0, this.Height) 
    });
    this.Region = new Region(path);
}

실제 행동 구현이 진행되는 한 : 아마도 다음을 원할 것입니다.

  • 가시 영역 밖으로 이동하면 스크롤 홀더로 스크롤하십시오.
  • 스크롤 홀더로 스크롤 할 때 Thread.Sleep 짧은 시간 (예 : 50ms).

다른 팁

당신은 설정해야합니다 MinExtra 의 속성 Splitter 큰 음수로. 속성 자체는 이것을 허용하지 않지만 반사를 통해 필드를 변경할 수 있습니다.

typeof(Splitter).GetField("minExtra", Reflection.BindingFlags.Instance | Reflection.BindingFlags.NonPublic).SetValue(mySplitter, -10000);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top