DataGridViewFilterSortElement라는 여러 UserControls를 포함 할 수있는 FlowPanelLayout이 있습니다. 이러한 컨트롤은 버튼과 비슷하지만 모양이 다릅니다. 사용자가 DataGridViewFilterSortElement 컨트롤 중 하나를 클릭하여 FlowLayoutPanel의 다른 위치 (인덱스)로 드래그 할 수있게하려고합니다.DragDrop을 통해 FlowLayoutPanel 컨트롤 이동
사용자가 컨트롤을 다른 위치로 드래그 할 때 컨트롤이 실제로 움직이는 것을 볼 수있는 방법이 있습니까? 즉, 커서가 움직일 때 실제 컨트롤이 움직이는 것을 보여줄 수있는 (그림자 상자 대신) 드래그되는 컨트롤의 "스냅 샷"을 가져 오는 방법이 있습니까? 또한 컨트롤이 드래그되는 동안 사용자가 드래그를 놓아서 교대조를보기를 기다리지 않고 자동으로 다른 컨트롤의 위치를 변경하고 싶습니다.
예를 들어 FlowPanelLayout에 3 개의 컨트롤이 있고 사용자가 첫 번째 컨트롤을 세 번째 컨트롤 위치로 드래그하려고한다고 가정 해 봅시다. 따라서 사용자가 첫 번째 DataGridViewFilterSortElement를 클릭하고 유지 한 다음 두 번째 컨트롤을 드래그하여 두 번째 컨트롤이 위치 1의 3으로 이동 한 다음 사용자가 세 번째 컨트롤 위로 드래그하면 세 번째 컨트롤이 두 번째 컨트롤로 이동합니다. 3이면 사용자가 컨트롤을 위치 3에 놓습니다. 이것이 가능합니까? 내가 가지고있는 작은 코드는 아래와 같습니다. 여기
는 내가하고 싶은 것을 보여줍니다 짧은 작은 비디오입니다 : http://www.youtube.com/watch?v=YhyTni6KH0QPrivate Sub lblDescription_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown, lblDescription.MouseDown
' if the user left clicks and holds the element begin a DragDrop action
If e.Button = Windows.Forms.MouseButtons.Left Then
Me.DoDragDrop(Me, DragDropEffects.Move)
End If
End Sub
Private Sub SortFlowLayoutPanel_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragOver
e.Effect = DragDropEffects.Move
End Sub
Private Sub SortFlowLayoutPanel_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles SortFlowLayoutPanel.DragDrop
If e.Data.GetData(GetType(DataGridViewFilterSortElement)) IsNot Nothing Then
'Current Position
Dim myIndex As Integer = Me.SortFlowLayoutPanel.Controls.GetChildIndex(CType(e.Data.GetData(GetType(DataGridViewFilterSortElement)), DataGridViewFilterSortElement))
'Dragged to control to location of next picturebox
Dim element As DataGridViewFilterSortElement = CType(e.Data.GetData(GetType(DataGridViewFilterSortElement)), DataGridViewFilterSortElement)
Me.SortFlowLayoutPanel.Controls.SetChildIndex(element, myIndex)
End If
End Sub
Private Sub SortFlowLayoutPanel_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles SortFlowLayoutPanel.DragOver
e.Effect = DragDropEffects.Move
End Sub
fyi이 방법을 사용하면 위치를 차지할 다른 컨트롤 위에 컨트롤을 드래그해야합니다. 따라서 3 개의 버튼이 있고 1을 3으로 만들려면 1을 3 위로 드래그하십시오. 마지막 컨트롤이 끝나면 아무 데나 놓을 수 없습니다. 이상적입니다. – DontFretBrett
404 - 링크가 이제 죽은 것 같습니다. –
어딘가에 캐시 된 버전을 찾을 수 있지만 거의 5 년 전의 예입니다. – DontFretBrett