2013-03-25 2 views
12

FlowLayoutPanel에 문제가 있으며 해결 방법을 모르겠습니다.FlowLayoutPanel.AutoSize를 FlowBreak와 함께 사용하는 방법

두 개의 FlowLayoutPanels를 다른 내부에 배치합니다. 두 번째 내부 flp에는 3 개의 버튼이 있습니다. FlowLayoutPanel 아이에서

enter image description here

속성은 다음과 같습니다

FlowDirection = LeftToRight; 
AutoSize = true; 
AutoSizeMode = GrowAndShrink; 
WrapContents = true; 

가 지금은 각 버튼에 대해 true로 FlowBreak 속성을 설정, 내가 볼 그러나 행동은 내가 원하는 것이 아니다, 내가 원하는 FlowLayoutPanel는

enter image description here

는 변경 버튼의 폭을 축소하는 FlowDirection ~ UpToDown은 (는) 옵션이 아닙니다.

누구나 AutoSize가 작동하지 않는 이유를 알고 계십니까?

이것은 코드입니다.

// 
//FlowLayoutPanel1 
// 
this.FlowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 
this.FlowLayoutPanel1.Controls.Add(this.FlowLayoutPanel3); 
this.FlowLayoutPanel1.Location = new System.Drawing.Point(84, 77); 
this.FlowLayoutPanel1.MinimumSize = new System.Drawing.Size(10, 10); 
this.FlowLayoutPanel1.Name = "FlowLayoutPanel1"; 
this.FlowLayoutPanel1.Size = new System.Drawing.Size(308, 265); 
this.FlowLayoutPanel1.TabIndex = 0; 
// 
//FlowLayoutPanel3 
// 
this.FlowLayoutPanel3.AutoSize = true; 
this.FlowLayoutPanel3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 
this.FlowLayoutPanel3.Controls.Add(this.Button1); 
this.FlowLayoutPanel3.Controls.Add(this.Button2); 
this.FlowLayoutPanel3.Controls.Add(this.Button3); 
this.FlowLayoutPanel3.Location = new System.Drawing.Point(127, 3); 
this.FlowLayoutPanel3.MinimumSize = new System.Drawing.Size(10, 10); 
this.FlowLayoutPanel3.Name = "FlowLayoutPanel3"; 
this.FlowLayoutPanel3.Size = new System.Drawing.Size(162, 87); 
this.FlowLayoutPanel3.TabIndex = 1; 
// 
//Button1 
// 
this.FlowLayoutPanel3.SetFlowBreak(this.Button1, true); 
this.Button1.Location = new System.Drawing.Point(3, 3); 
this.Button1.Name = "Button1"; 
this.Button1.Size = new System.Drawing.Size(75, 23); 
this.Button1.TabIndex = 0; 
this.Button1.Text = "Button1"; 
this.Button1.UseVisualStyleBackColor = true; 
// 
//Button2 
// 
this.FlowLayoutPanel3.SetFlowBreak(this.Button2, true); 
this.Button2.Location = new System.Drawing.Point(3, 32); 
this.Button2.Name = "Button2"; 
this.Button2.Size = new System.Drawing.Size(75, 23); 
this.Button2.TabIndex = 1; 
this.Button2.Text = "Button2"; 
this.Button2.UseVisualStyleBackColor = true; 
// 
//Button3 
// 
this.Button3.Location = new System.Drawing.Point(3, 61); 
this.Button3.Name = "Button3"; 
this.Button3.Size = new System.Drawing.Size(75, 23); 
this.Button3.TabIndex = 2; 
this.Button3.Text = "Button3"; 
this.Button3.UseVisualStyleBackColor = true; 
+0

이 내 GUI에서 문제가 하나의 제어 난에 FlowBrake 2 컨트롤을 넣어 설정 https://docs.google.com/document/d/1I6OtboresNk-gfOR3sEM8gyYHVX9sGohdNtX6heeQwI/edit?usp=sharing True https://docs.google.com/document/d/17C02PoL8LCyymfXNtEP8N6kkzZETxkiOCb6mPTbzGf0/edit?usp = sharing 컨트롤을 계속 유지하고 싶지만 너비가 맞지 않아야합니다. – Natalia

+0

두 이미지를 추가 할 수 있습니까? 하나는 보유하고 보유하고 다른 하나는 달성하려는 것입니다. 텍스트 설명에서 당신이 직면하고있는 문제가 무엇인지 명확하지 않습니다 –

+0

결과가 새 이미지로 추가되었습니다. 이전 주석에서 GUI의 동작과 두 개의 링크를 추가했습니다. – Natalia

답변

13

버그입니다. 오랜 시간 동안 발생했습니다. 문제는 FlowLayoutPanel의 레이아웃 엔진이 두 번째 행으로 래핑되었지만 두 번째 컨트롤의 너비를 포함하여 첫 번째 행의 너비를 잘못 계산한다는 것입니다.

해결 방법은 바보 같지만 효과적입니다. 첫 번째 컨트롤 뒤에 너비가 0 인 더미 패널을 추가하십시오. 디자이너와 함께이 작업을 수행하는 경우 먼저 놓고 첫 번째 컨트롤의 오른쪽에 올바른 위치로 끕니다. 그런 다음 등록 정보 창에서 여백을 (0, 0, 0, 0) 및 크기 (0, 0)로 설정하십시오.

+0

저장된 내 하루 .. 감사합니다 !! – vendettamit

2

해결책은 아니지만 해결 방법입니다. FlowLayoutPanel에서 흐름 나누기를 사용하여 TableLayoutPanel의 동작을 시뮬레이션하려는 것 같습니다. 대신 TableLayoutPanel을 사용해 보셨습니까? 의견에있는 귀하의 스크린 샷에 따르면, 그것은 귀하의 필요에 완벽하게 작동합니다.

+0

내 gui에서 사용자는 모든 버튼의 순서와 위치를 정렬 할 수 있습니다. 사용자는 또한 컨테이너 안팎으로 버튼을 드래그 앤 드롭 할 수 있습니다. 테이블 레이아웃 패널을 만든 다음 사용자가 컨트롤을 드롭하면 컨트롤의 행이나 행 또는 테이블을 가질 수 있기 때문에 테이블의 동작이 간단하지 않습니다. – Natalia

+0

@Natalia : [this] (http://www.devexpress.com/Products/NET/Controls/WinForms/Layout/)을 구현하려고합니까? – Neolisk

6

저는 FlowLayoutPanel이 당신이하려는 일을하기 위해 디자인 된 것이라고 생각하지 않습니다. TableLayoutPanel이 더 적합 할 것입니다. 단일 열을 가진 TableLayoutPanel을 추가하고 각 버튼을 행에 추가하십시오.

편집 : 주변에서 해킹 된 작업을 발견했습니다. 첫 번째 버튼 다음에 패널을 만듭니다. 크기는 0,0이고 여백은 0,0입니다. FlowBreak이 false로 설정되어 있는지 확인하십시오.

enter image description here

편집 : 당신은, 첫 번째 단추 후, 하나 개의 패널을 만들 필요가 각각 없습니다 하나.

+1

같은 생각, 같은 시간. Upvoting ... :) – Neolisk

+0

@Michael G 나는 이것을 시도 할 것이고, 몇 분을 기다릴 것이다. – Natalia

+1

당신의'hackish work around'는 놀랍다. 나는 그런 것을 찾으려고했지만 패널 컨트롤이 내 마음에 오지 않았다. 나는 너에게 또 다른 업보트를 줄 수 있었으면 좋겠다. – Neolisk