WinForms를 사용하여 실제 프로그램에서 문제가 발생하면 최소한의 테스트 응용 프로그램을 만들고 있습니다. 나는 더 큰 패널 (부모) 안에 작은 패널 (자식)을 넣었다. 더 큰 패널에는 AutoScroll이 true로 설정됩니다. 하위 패널에는 기본 앵커가 위쪽 및 왼쪽으로 설정되어 있습니다. 하위 패널이 고정되어 있지 않습니다.패널의 패널, 자동 스크롤
원하는 동작은 작은 패널의 위치가 위쪽, 아래쪽, 왼쪽 또는 오른쪽으로 너무 오프셋 될 때마다 스크롤 막대가 표시되도록하는 것입니다. 문제는 그것이 너무 멀리 떨어져 있거나 너무 멀리있을 때만 작동한다는 것입니다. 스크롤바가 너무 많거나 왼쪽 방향으로 너무 많이있을 때는 스크롤바가 나타나지 않습니다.
두 개의 간단한 버튼을 사용하여 하위 패널의 위치를 왼쪽으로 200 픽셀, 오른쪽으로 200 픽셀로 설정하면 위치를 쉽게 수정할 수 있습니다. 빨리 WPF 해결 Another 윈폼 불능 -
private void InitializeComponent()
{
this.hostPanel = new System.Windows.Forms.Panel();
this.childPanel = new System.Windows.Forms.Panel();
this.moveChildLeft = new System.Windows.Forms.Button();
this.moveChildRight = new System.Windows.Forms.Button();
this.hostPanel.SuspendLayout();
this.SuspendLayout();
//
// hostPanel
//
this.hostPanel.AutoScroll = true;
this.hostPanel.BackColor = System.Drawing.SystemColors.AppWorkspace;
this.hostPanel.Controls.Add(this.childPanel);
this.hostPanel.Location = new System.Drawing.Point(239, 48);
this.hostPanel.Name = "hostPanel";
this.hostPanel.Size = new System.Drawing.Size(400, 400);
this.hostPanel.TabIndex = 0;
//
// childPanel
//
this.childPanel.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.childPanel.Location = new System.Drawing.Point(29, 62);
this.childPanel.Name = "childPanel";
this.childPanel.Size = new System.Drawing.Size(342, 259);
this.childPanel.TabIndex = 0;
//
// moveChildLeft
//
this.moveChildLeft.Location = new System.Drawing.Point(61, 81);
this.moveChildLeft.Name = "moveChildLeft";
this.moveChildLeft.Size = new System.Drawing.Size(75, 23);
this.moveChildLeft.TabIndex = 1;
this.moveChildLeft.Text = "Left 200";
this.moveChildLeft.UseVisualStyleBackColor = true;
this.moveChildLeft.Click += new System.EventHandler(this.button1_Click);
//
// moveChildRight
//
this.moveChildRight.Location = new System.Drawing.Point(61, 111);
this.moveChildRight.Name = "moveChildRight";
this.moveChildRight.Size = new System.Drawing.Size(75, 23);
this.moveChildRight.TabIndex = 2;
this.moveChildRight.Text = "Right 200";
this.moveChildRight.UseVisualStyleBackColor = true;
this.moveChildRight.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1018, 549);
this.Controls.Add(this.moveChildRight);
this.Controls.Add(this.moveChildLeft);
this.Controls.Add(this.hostPanel);
this.Name = "Form1";
this.Text = "Form1";
this.hostPanel.ResumeLayout(false);
this.ResumeLayout(false);
}
고정되어있는 경우 어떻게 위쪽이나 왼쪽으로 지나치게 많을 수 있습니까? –
하위 패널의 앵커 속성을 제거하면 (즉, none으로 설정 한 경우) 하위 패널의 위치에 관계없이 호스트 패널에 스크롤 막대가 전혀 표시되지 않습니다. 자동 스크롤 막대는 어딘가에 적어도 1 개의 앵커가 있는지에 따라 달라집니다. –