Solved

VB.net DataGridView double click

Posted on 2014-04-23
2
2,063 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:murbro
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:murbro
ID: 40026646
Thanks very much
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now