Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to make  dragdrop - mousedown & cell click work in same datagridview

Posted on 2011-10-05
8
Medium Priority
?
1,211 Views
Last Modified: 2012-05-12
I have a winform application written in VS 2010. It has two datagridviews on the form: Gridview1 and Gridview2.    There is a checkbox column on Gridview1 in addition to other text columns.    I recently added a dragDrop event to enable user to dragdrop rows from Gridview1 to Gridview2. However, I found the Click event is no longer evoked on gridview1 after I added MouseDown event to do dragdrop.

 I understand that both Click cell and dragdrop actions evok the mouseDown event, but the chanllenge is how I can make the program to recognize these two different actions?

Any help is greatly appreciated.!!
0
Comment
Question by:jrmc-pgmr
  • 5
  • 3
8 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36921213
What do you have in mouse down? And what do you want the click event for?
0
 

Author Comment

by:jrmc-pgmr
ID: 36922273
Mouse down to drag drop data from gridview1 to gridview 2.
Click event for check the checkbox cell in gridview1.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36926931
Show us the code from mouse down. It should not be a problem generally.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:jrmc-pgmr
ID: 36927132
   Private Sub VisitHIGridView_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles VisitHIGridView.MouseDown

          Dim hit As DataGridView.HitTestInfo = VisitHIGridView.HitTest(e.X, e.Y)
          Dim clickedRow As DataGridViewRow = New DataGridViewRow
         rowIndexFromMouseDown = VisitHIGridView.HitTest(e.X, e.Y).RowIndex

        If hit.Type = DataGridViewHitTestType.Cell Then
                 clickedRow = VisitHIGridView.Rows(hit.RowIndex)
                VisitHIGridView.DoDragDrop(clickedRow, DragDropEffects.Copy)
        End If

    End Sub

'Destination gridview
    Private Sub PlanGridView_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PlanGridView.DragEnter

                   e.Effect = DragDropEffects.Copy
        End Sub
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36927150
Try moving that code to MouseClick event.
0
 

Assisted Solution

by:jrmc-pgmr
jrmc-pgmr earned 0 total points
ID: 36927676
The drag drop is  no longer working after I moved the code to Mouseclick event.
0
 

Accepted Solution

by:
jrmc-pgmr earned 0 total points
ID: 36933056
I have figured it our myself. By using MouseDown and MouseMove events. so I now I can do both dragdrop and click cell in same grid now. Thanks
0
 

Author Closing Comment

by:jrmc-pgmr
ID: 36954303
I figured it out myself
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question