Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7495575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:13:11+00:00 2026-05-29T18:13:11+00:00

Well the title pretty well describes my problem. Here is a little bit more

  • 0

Well the title pretty well describes my problem. Here is a little bit more detailed description of my problem:

I am building an application with a TabControl, which I populate at execution time with TabPages. In my first version of the code, these TabPages were filled with a children ListView. The ListView was also created in code, using AddHandlers to link it to the DragEnter and DragDrop routines. Everything worked very well…

Now as I need some other controls on every TabPage, instead of creating every single control in code, I have created a UserControl containing a ListView and a few Buttons, which I instantiate for every new TabPage.

The problem now is that the DragDrop event is not raised anymore

  • DragEnter event –> raised OK
  • DragOver event –> raised OK
  • DragLeave event –> raised OK
  • DragDrop event –> not raised !!

This problem is driving me crazy: any thoughts on what I could be missing?

I don’t think the code will be of any help, but to answer the first comment:
First Version: controls created in code (works):

    Dim NewTab As New TabPage(TextBox1.Text)
    Dim NewListView As New ListView()
    Dim NewImageList As New ImageList()

    'Organise les nouveaux contrôles
    NewListView.Parent = NewTab
    NewListView.Dock = DockStyle.Fill
    NewListView.View = View.LargeIcon
    NewListView.LargeImageList = NewImageList
    NewListView.AllowDrop = True
    AddHandler NewListView.DoubleClick, AddressOf ListViewItem_DblClick
    AddHandler NewListView.DragEnter, AddressOf ListViewItem_DragEnter
    AddHandler NewListView.DragDrop, AddressOf ListViewItem_DragDrop
    TabControl1.TabPages.Add(NewTab)
    TabControl1.SelectTab(NewTab)
    NewImageList.ImageSize = New Size(100, 100)
    NewImageList.ColorDepth = ColorDepth.Depth24Bit

    TabControl1.Refresh()

Second version: Usercontrol (does not work):
First, imagine a user control TabAnnoncesContent, which contains a AnnoncesListView, and an AnnoncesImageList

    Dim NewTab As New TabPage(TextBox1.Text)
    Dim NewTabContent As New TabAnnoncesContent()

    NewTabContent.Parent = NewTab
    NewTabContent.Dock = DockStyle.Fill

    TabControl1.TabPages.Add(NewTab)
    TabControl1.SelectTab(NewTab)

    TabControl1.Refresh()

Then inside my TabAnnoncesContent class code I have:

Private Sub AnnoncesListView_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles AnnoncesListView.DragDrop
    Dim selection As ListViewItem = sender.HitTest(sender.PointToClient(New Point(e.X, e.Y))).Item

    If (selection IsNot Nothing) Then
        MsgBox("D&D received -> " & e.Data.GetData(DataFormats.Text))
    End If
End Sub

Private Sub AnnoncesListView_DragEnter(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles AnnoncesListView.DragEnter
    If (e.Data.GetDataPresent(DataFormats.Text)) Then
        ' Display the copy cursor.
        e.Effect = DragDropEffects.Link
    Else
        ' Display the no-drop cursor.
        e.Effect = DragDropEffects.None
    End If
End Sub

The AnnonceListView_DragEnter routines is executed when I enter the ListView with text, but then when I release the mouse, the AnnonceListView_DragDrop event is never raised.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T18:13:15+00:00Added an answer on May 29, 2026 at 6:13 pm

    Not using Option Strict On in your code is a Visual Basic convenience. You’ll get runtime errors instead of compile errors when you get the code wrong. That’s doesn’t work out well in drag+drop code though, the events are called with a back-stop that swallows all exceptions. The only diagnostic you’ll get is a first chance exception notification in the Output window. Very easy to miss of course.

    Anyhoo, Debug + Exceptions, Thrown checkbox to get the debugger to stop on the exception. And Option Strict On at the top of your source code file to catch these kind of mistakes early. That does however require a different code writing style, more akin to C#.

    Btw, you should also implement the DragOver event. So you can call the ListView’s HitTest() method and check that the user is actually hovering over a ListViewItem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

well, the title pretty much says it all. here's a little info: i have
Think the title describes my thoughts pretty well :) I've seen a lot of
Well, the title pretty much describes my question: How to load the background-image dynamically
Well the title pretty much sums the question. The only thing I found is
Well, the title's pretty much it: if I sat a non-techie/my mum/twelve-year old boy/cocker
The title explains it pretty well, but I'm trying to build a 'for loop'
My title sums this up pretty well. My first though it to provide a
Well, title self describes it.. I need to run a sql function to clean
Well the title pretty much says it all. I had: $strata = new Zend_Form_Element_Select('strata');
Well, the title pretty much sums it up, really. I've only just started toying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.