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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:27:25+00:00 2026-06-08T08:27:25+00:00

In a Windows App (Visual Studio)(VB) how do you drag and drop a single

  • 0

In a Windows App (Visual Studio)(VB) how do you drag and drop a single row to another postition to allow for the user to re-order the row? I haven’t found any worthy examples for this yet.

  • 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-06-08T08:27:27+00:00Added an answer on June 8, 2026 at 8:27 am

    Here is a vb version from this C# answer: How could I Drag and Drop DataGridView Rows under each other?

    The form class variables:

    Private fromIndex As Integer
    Private dragIndex As Integer
    Private dragRect As Rectangle
    

    The drag events:

    Private Sub DataGridView1_DragDrop(ByVal sender As Object, _
                                       ByVal e As DragEventArgs) _
                                       Handles DataGridView1.DragDrop
      Dim p As Point = DataGridView1.PointToClient(New Point(e.X, e.Y))
      dragIndex = DataGridView1.HitTest(p.X, p.Y).RowIndex
      If (e.Effect = DragDropEffects.Move) Then
        Dim dragRow As DataGridViewRow = e.Data.GetData(GetType(DataGridViewRow))
        DataGridView1.Rows.RemoveAt(fromIndex)
        DataGridView1.Rows.Insert(dragIndex, dragRow)
      End If
    End Sub
    
    Private Sub DataGridView1_DragOver(ByVal sender As Object, _
                                       ByVal e As DragEventArgs) _
                                       Handles DataGridView1.DragOver
      e.Effect = DragDropEffects.Move
    End Sub
    

    The mouse events:

    Private Sub DataGridView1_MouseDown(ByVal sender As Object, _
                                        ByVal e As MouseEventArgs) _
                                        Handles DataGridView1.MouseDown
      fromIndex = DataGridView1.HitTest(e.X, e.Y).RowIndex
      If fromIndex > -1 Then
        Dim dragSize As Size = SystemInformation.DragSize
        dragRect = New Rectangle(New Point(e.X - (dragSize.Width / 2), _
                                           e.Y - (dragSize.Height / 2)), _
                                 dragSize)
      Else
        dragRect = Rectangle.Empty
      End If
    End Sub
    
    Private Sub DataGridView1_MouseMove(ByVal sender As Object, _
                                        ByVal e As MouseEventArgs) _
                                        Handles DataGridView1.MouseMove
      If (e.Button And MouseButtons.Left) = MouseButtons.Left Then
        If (dragRect <> Rectangle.Empty _
        AndAlso Not dragRect.Contains(e.X, e.Y)) Then
          DataGridView1.DoDragDrop(DataGridView1.Rows(fromIndex), _
                                   DragDropEffects.Move)
        End If
      End If
    End Sub
    

    Make sure you have the grids AllowDrop property set to true.

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

Sidebar

Related Questions

I'm working with an old windows app in visual studio 2005. A webserviced referenced
JI have written a .NET C# Windows Form app in Visual Studio 2008 that
I am working on a Metro-app for Windows 8 and using MS Visual Studio
I have a simple Windows App written in Visual Studio 2008 (.NET 3.0, C#).
I am developing a Windows CE App using Visual Studio 2008 and the Compact
When I develop a Windows Forms app in Visual Studio using C#, every control
I'm writing a Windows Forms app in C#, using Visual Studio 2010. It has
I'm trying to install my Windows Service app using Visual Studio 2008 Setup and
I am using Visual Studio 2008 to create a windows app. I want to
I have a multi-threaded Windows C++ app written in Visual Studio 6. Within the

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.