Solved

VB.net DataGridView double click

Posted on 2014-04-23
2
2,295 Views
Last Modified: 2014-04-27
Hi
I have an Excel add-in where I am trying to get information from a DataGridView onto
a spreadsheet with the code below. The problem is that it doesn't work every time I double click. Is there a better way to do this


    Private Sub DataGridView1_CellDoubleClick(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
        Try
            Dim oRowIndex As Integer = e.RowIndex
            Dim oColumnIndex As Integer = e.ColumnIndex
            Dim oDescription As String = Me.DataGridView1.Rows(oRowIndex).Cells(1).Value
            Dim oPrice As String = Me.DataGridView1.Rows(oRowIndex).Cells(2).Value
            Dim oPriceExVAT As String = Me.DataGridView1.Rows(oRowIndex).Cells(3).Value

            Dim oActiveCellRow As Long = Globals.ThisAddIn.Application.ActiveCell.Row
            Globals.ThisAddIn.Application.Cells(oActiveCellRow, 1).value = oDescription
            Globals.ThisAddIn.Application.Cells(oActiveCellRow, 2).value = oPrice
            Globals.ThisAddIn.Application.Cells(oActiveCellRow, 3).value = oPriceExVAT

        Catch ex As Exception
            MsgBox(ex.Message & " 8bb")
        End Try
    End Sub
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
dj_alik earned 500 total points
ID: 40019341
Try the CellMouseDoubleClick event...

Private Sub DataGridView1_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseDoubleClick
    If e.RowIndex >= 0 AndAlso e.ColumnIndex >= 0 Then
        Dim selectedRow = DataGridView1.Rows(e.RowIndex)
    End If
End Sub
0
 

Author Closing Comment

by:Murray Brown
ID: 40026646
Thanks very much
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

627 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