Hello!
I have an application that has two list box controls, and I've tried to enable the drag and drop feature between the two lists, but I have some problems, I want to combine the drag and drop with some other features:
1-The list box has the multi extended selection mode enabled.
2-The double-click on an item opens a form with the selected item properties.
3-The right click opens a context menu.
I've tried to use a custom control that I found on this forum, but I still have bugs with the double click, sometimes "enables" the drag and drop instead of opening the properties form. Here is the custom control I'm using:
https://www.vbforums.com/showthread....=1#post3079759
Here are the methods I'm using:
EDIT:
This custom control, gives me the option to select rows by clicking one row and dragging it, as we can do in Excel, for example. The idea is to combine this with the drag and drop and also allowing the double click.
I have an application that has two list box controls, and I've tried to enable the drag and drop feature between the two lists, but I have some problems, I want to combine the drag and drop with some other features:
1-The list box has the multi extended selection mode enabled.
2-The double-click on an item opens a form with the selected item properties.
3-The right click opens a context menu.
I've tried to use a custom control that I found on this forum, but I still have bugs with the double click, sometimes "enables" the drag and drop instead of opening the properties form. Here is the custom control I'm using:
https://www.vbforums.com/showthread....=1#post3079759
Here are the methods I'm using:
Code:
Private Sub ListBox_DataBaseSFX_MouseMove(sender As Object, e As MouseEventArgs) Handles ListBox_DataBaseSFX.MouseMove
If sender IsNot Nothing AndAlso e.Button = MouseButtons.Left AndAlso e.Clicks = 1 Then
ListBox_DataBaseSFX.DoDragDrop(ListBox_DataBaseSFX.SelectedItems, DragDropEffects.Move)
End If
End Sub
Private Sub ListBox_DataBaseSFX_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles ListBox_DataBaseSFX.MouseDoubleClick
'Ensure that we have selected an item
Dim itemIndex = ListBox_DataBaseSFX.IndexFromPoint(e.Location)
If itemIndex <> ListBox.NoMatches Then
'Get item and file path
Dim selectedSFX As String = ListBox_DataBaseSFX.Items(itemIndex)
'Open editor
Dim sfxEditor As New SfxEditor(selectedSFX)
sfxEditor.ShowDialog()
End If
End Sub
Private Sub ListBox_DataBaseSFX_DragOver(sender As Object, e As DragEventArgs) Handles ListBox_DataBaseSFX.DragOver
e.Effect = DragDropEffects.Copy
End Sub
Private Sub ListBox_DataBaseSFX_DragDrop(sender As Object, e As DragEventArgs) Handles ListBox_DataBaseSFX.DragDrop
If e.Effect = DragDropEffects.Copy AndAlso ListBox_DataBases.SelectedItems.Count > 0 Then
If e.Data.GetDataPresent(GetType(ListBox.SelectedObjectCollection)) Then
Dim itemsData As ListBox.SelectedObjectCollection = e.Data.GetData(GetType(ListBox.SelectedObjectCollection))
For Each data As String In itemsData
ListBox_DataBaseSFX.Items.Add(data)
Next
End If
End If
End Sub
This custom control, gives me the option to select rows by clicking one row and dragging it, as we can do in Excel, for example. The idea is to combine this with the drag and drop and also allowing the double click.