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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:21:40+00:00 2026-05-31T13:21:40+00:00

I am writing a control in vb.net that will allow a user to resize

  • 0

I am writing a control in vb.net that will allow a user to resize something. So far, resizing works, but I can’t get moving to work properly, instead of moving where the mouse moves, it seems to flicker between two positions, but I can’t figure out where these positions are coming from. It follows the mouse sort of. I know the explanation isn’t very good so here is some code so you can see for your self: pastebin.

Apologies for this bad quality (please point out the bad stuff so I can correct), but this is really giving me a nightmare and I couldn’t figure out a clean way to write this.

If anyone has any answers as to why it wont move to the correct position, I would be very grateful!

Edit: To clear the code up a little, the moving takes place where the selected handle is “m”. Which is this part:

If SelectedHandle.Contains("m") Then
    If e.Button = MouseButtons.None Then
        SelectedHandle = ""
    Else
        Me.Location = e.Location
    End If
End If

Changing it to this works, but it jumps to the middle of the control whereas I would like it to move relative to where the user clicked the mouse on the control

If SelectedHandle.Contains("m") Then
    If e.Button = MouseButtons.None Then
        SelectedHandle = ""
    Else
        Dim newloc = Me.Location
        newloc.Offset(e.X, e.Y)
        newloc.Offset(-0.5 * Width, -0.5 * Height)
        Me.Location = newloc
    End If
End If
  • 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-31T13:21:41+00:00Added an answer on May 31, 2026 at 1:21 pm

    Looks like y_difference and x_difference are calculated using the X and Y coordinates which can be relative to the context where the move (or click) happens. Check the article here.

    For example, when the Control.MouseMove event is handled, the mouse coordinate values are relative to the coordinates of the control that raised the event

    Always using e.Location should give the correct numbers.

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

Sidebar

Related Questions

I'm writing a calendar control in .Net WinForms that will show a tooltip for
I'm writing my first asp.net user control. It displays a list of locations that
I'm trying to build an application that will allow the user to setup N
I am writing an ASP.NET custom control. In my custom control code, I find
Has anyone had any experience writing a web control (in either ASP.net, or javascript/HTML/CSS),
I'm writing a user control in WPF which is based on a ListBox. One
I am writing an access control program in Java that captures passwords using JPasswordField
I'm writing a custom compound control that extends RelativeLayout. Inside this component, there is
I have some commercial equipment that I can connect to with a .Net library
I'm writing a .NET web application in which administrators can customize the various data

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.