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 4082094
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:08:41+00:00 2026-05-20T18:08:41+00:00

I followed the solution to the items rearranging problem provided by dnr3. Works like

  • 0

I followed the solution to the items rearranging problem provided by dnr3. Works like a charm and it is very easy to understand. Now, I wish to go one step further:

Let’s say that ListBox contains items A, B, C, D and E. In the mentioned solution, if a ListBoxItem is moved down the list, it is positioned below the item on which the drop was executed. So, if I select item B and release it over the element D, it will take D’s place and D will move one place down. I want to be able to make a difference if the dragged item is closer to the upper or lower target item boundary – if it is closer to the upper I want it placed above the target item, or below if otherwise. I need two things to make that happen:

  1. I need the vertical center point of the target item in order to be able to compare it with mouse position. That should be easy to do:

    targetItem.Height / 2;

  2. I need mouse position relative to the target item. How do I get that?

In the end I want to compare those two values and if mouse position is less than or equal to the item’s vertical center point, then the dragged item gets to be dropped before the target item, otherwise below.

Thanks!

  • 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-20T18:08:42+00:00Added an answer on May 20, 2026 at 6:08 pm

    Got it! The following line retrieves the mouse position relative to target item
    Point p = e.GetPosition(item);

    Here’s what the drop event handler should look like:

    private void PlaylistListBoxItem_Drop(object sender, DragEventArgs e)
    {
        ...
        ListBoxItem item;
        int centerY;
        Point p;
    
        item = sender as ListBoxItem;
        centerY = item.Height / 2;
        p = e.GetPosition(item);
    
        if (p.Y <= centerY)
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have followed reply from BalusC to resolve my problem How do I make
I followed couple of links and i'm still having problem in deploying servlet page.
[SOLVED: See solution below.] I'm having a problem writing a RewriteMap program (using Python).
My application downloads and displays favicons for specific websites. I followed Bing's solution for
UPDATED SOLUTION: With my particular problem, the sort call was inside a Render function
I currently have a problem concerning the behaviour of floating items, and containers not
I have this strange, yet maybe very simple problem.. I have a timer1 in
Followed this question about delayed_job and monit Its working on my development machine. But
I followed the explanation on the sIFR wiki, but can't seem to get accented
I followed along this tutorial for django's RSS and ATOM feeds and I got

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.