2012-09-06 27 views
0

我有一个Windows窗体应用程序正在使用FlowLayoutPanel控件来显示动态构建的图片框。我已经启用,因为他们可能要重新排序的拖放效果,这个工程只有少数图片框罚款(现在屏幕上显示出约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(); 
    } 
} 

希望这有助于他人。