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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:43:45+00:00 2026-05-29T23:43:45+00:00

I have form in VB.Net 2010: I want to click-drag multi rows in dgRegister

  • 0

I have form in VB.Net 2010:

enter image description here

I want to click-drag multi rows in dgRegister and Date, Course ID to drop in dgCourseStudent with column Date, Register ID, Register Name and Course ID.

How to code this in vb.net language?

  • 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-29T23:43:46+00:00Added an answer on May 29, 2026 at 11:43 pm

    First of all put the AllowDrop property of dgCourseStudent to True (it will accept the dragging events). I’ve presumed you’re using DataSet or DataTable, here my example:

     Dim downHitInfo As DataGridView.HitTestInfo = Nothing 'Used to keep trace of dragging info
    
    ''MouseDown used to know is a DragDrop event is required
    Private Sub dgRegister_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgRegister.MouseDown
        Dim view As DataGridView = CType(sender, DataGridView)
        Dim hitInfo As DataGridView.HitTestInfo = view.HitTest(e.X, e.Y)
        If Not Control.ModifierKeys = Keys.None Then
            Exit Sub
        End If
        If e.Button = MouseButtons.Left And hitInfo.RowIndex >= 0 Then
            downHitInfo = hitInfo
        End If
    End Sub
    
    ''MouseMove used to know what DataRow is being dragged.
    Private Sub dgRegister_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgRegister.MouseMove
        Dim view As DataGridView = CType(sender, DataGridView)
        If e.Button = MouseButtons.Left And Not downHitInfo Is Nothing Then
            Dim dragSize As Size = SystemInformation.DragSize
            Dim DragRect As Rectangle = New Rectangle(New Point(Convert.ToInt32(downHitInfo.ColumnX - dragSize.Width / 2), _
          Convert.ToInt32(downHitInfo.RowY - dragSize.Height / 2)), dragSize)
            If Not DragRect.Contains(New Point(e.X, e.Y)) Then
                'Extract the DataRow
                Dim gridRowView As DataGridViewRow = DirectCast(view.Rows(downHitInfo.RowIndex), DataGridViewRow)
                Dim rowView As DataRowView = DirectCast(gridRowView.DataBoundItem, DataRowView)
    
                'Raise the DragDrop with the extracted DataRow
                view.DoDragDrop(rowView.Row, DragDropEffects.Move)
                downHitInfo = Nothing
            End If
        End If
    End Sub
    
    '' For mouse cursor
    Private Sub dgCourseStudent_DragOver(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles dgCourseStudent.DragOver
        e.Effect = DragDropEffects.Move
    End Sub
    
    ''The core of draggin procedure
    Private Sub dgCourseStudent_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles dgCourseStudent.DragDrop
        'Retreive the dragged DataRow
        Dim draggedRow As DataRow = CType(e.Data.GetData(GetType(DataRow)), DataRow)
        ''
        '' Put your code here to insert the dragged row into dgCourseStudent grid
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a vb.net 2010 form with 22 data bound controls from two tables
I have an ASP.NET form (C#) but which I click this button that should
I have a VB.NET form with a red background and white text. I want
I have developed a Windows Form Application in Visual Studio 2010, i.e., using .Net
I have a form in VB.Net with Autoscroll enabled and several ComboBoxes within it.
Possible Duplicate: Read Post Data submitted to ASP.Net Form I have a google checkout
Windows form application(.Net 3.5) I have a textbox and a button on the form.
I have an asp.net form that contains some html, 2 controls a calendar from
i have an asp.net form and an asp:textbox. i have a problem when the
I have an ASP.NET form with three text inputs, one each for Work Phone,

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.