2012-09-06 1 views
0

나는 동적으로 빌드 된 그림 상자를 표시하기 위해 FlowLayoutPanel 컨트롤을 사용하는 Windows Forms 응용 프로그램이 있습니다. 드래그 드롭 효과를 사용하여 순서를 바꿀 수 있으므로 몇 개의 그림 상자만으로도 효과적이지만 (현재 화면에는 약 6 개가 표시됨) 더 많은 항목이 컨트롤 아래로 드래그하려고하면 스크롤을 사용하면 현재 화면에있는 이미지 (이미지 4)를 보이는 것보다 아래에있는 이미지 (이미지 13)에 넣을 수 없습니다.드래그하는 동안 flowlayoutpanel에서 스크롤링 하시겠습니까?

ScrollControllIntoViewMethod를 사용해야하는 곳을 여러 곳에서 보았습니다. 몇 곳을 성공적으로 시도하지 못했습니다.

감사합니다.

+0

다른 방법은 다음과 같습니다. http://stackoverflow.com/a/231486/17034 –

답변

1

여기 제가 끝난 것입니다.


는 낮은 경계를 얻을 수있는 컨트롤의 높이를 계산 제어
의 위치를 ​​얻기 DragLeave 이벤트
의 이벤트를 생성합니다.
마우스 위치를 확인하고, 상기 경계에 있으면, .. 상수의 값이 다른 도움

private void thumbFlow_DragLeave(object sender, EventArgs e) 
{ 
    int BegY_ThumbFlow = this.thumbFlow.FindForm().PointToClient(this.thumbFlow.Parent.PointToScreen(this.thumbFlow.Location)).Y; 
    int thumbFlowBound_Y = this.thumbFlow.Height + BegY_ThumbFlow; 
    int mouseY = this.thumbFlow.FindForm().PointToClient(MousePosition).Y; 

    while (mouseY >= thumbFlowBound_Y) 
    { 
     thumbFlow.VerticalScroll.Value = thumbFlow.VerticalScroll.Value + DRAG_DROP_SCROLL_AMT; 
     mouseY = thumbFlow.FindForm().PointToClient(MousePosition).Y; 
     thumbFlow.Refresh(); 
    } 

    while (mouseY <= BegY_ThumbFlow) 
    { 
     thumbFlow.VerticalScroll.Value = thumbFlow.VerticalScroll.Value - DRAG_DROP_SCROLL_AMT; 
     mouseY = thumbFlow.FindForm().PointToClient(MousePosition).Y; 
     thumbFlow.Refresh(); 
    } 
} 

희망 수직 스크롤 (또는 수평 스크롤)을 변경.