2013-05-17 3 views
0

.NET 3.5에서 winforms로 이미지 축소판 뷰어 컨트롤을 만들고 있습니다.스크롤 할 때 flowlayoutpanel의 하위 컨트롤 새로 고침

주 제어는 FlowLayoutPanel에서 파생되어 이미지 목록을 가져와 표시합니다. 표시되는 이미지는 CustomControl에서 만들어지며 컨트롤의 경계뿐만 아니라 레이블도 함께 그려집니다. 이미지를 클릭하거나 yada yada로 선택하면 해당 종류의 컨트롤을 기대할 수 있습니다.

는 여기 screenshote을 설명하기 위해입니다 :

enter image description here

그 부분은 잘 작동합니다.

enter image description here

I가 설정 한 양 FlowLayoutPanel 및 이미지 버퍼링 배로 : I 테두리가 적절히 묘화되지 않는 FlowLayoutPanel 유도 제어 스크롤이 스크린에 도시하는 바와 같이 나머지 라인이 존재하는 경우의 문제점은 다음이다 . 그리고 이미지와 라벨에는 문제가 없으므로 다른 것으로 의심되지만 그게 무엇인지 알 수는 없습니다.

이미지 테두리를 페인트하는 데 사용 된 방법이 잘못되었을 수 있습니다.

protected override void OnPaint(PaintEventArgs e) 
    { 
     Rectangle captionContainer; 

     captionContainer = new Rectangle(); 
     if (!string.IsNullOrEmpty(this.Caption)) 
      captionContainer = this.DrawCaption(e.Graphics); 

     if (this.Image != null) 
      this.DrawImage(e.Graphics, captionContainer); 

     this.Size = new Size(this.Padding.Horizontal + this.ImageSize.Width, this.Padding.Vertical + this.ImageSize.Height + captionContainer.Height); 

     ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, this.currentBorderColor, ButtonBorderStyle.Solid); 

     base.OnPaint(e); 
    } 

필요한 경우 좀 더 코드를 게시 할 수 있습니다,하지만 꽤 긴, 그래서 실제로 필요한 경우가 아니면 내가 너무 많은 코드를 삽입하고 싶지 않은 : 여기 내가 사용하는 코드입니다.

어디서 잘못 알 수 있습니까?

+0

해결되었습니다. 위의 방법으로 정확히 무엇이 잘못되었는지 알고 싶습니다. –

답변

1

Graphics 개체를 사용하여 경계선을 그려서 해결했습니다.

e.Graphics.DrawRectangle(new Pen(this.currentBorderColor, 1F), new Rectangle(Point.Empty, new Size(this.Width - 1, this.Height - 1))); 

ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, this.currentBorderColor, ButtonBorderStyle.Solid); 

교체 트릭을 수행합니다. 왜 다른 사람이 아닌 다른 사람이 작동하는지 모르겠다. ...

관련 문제