Solved

VB.net DataGridView double click

Posted on 2014-04-23
2
2,014 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

12 Experts available now in Live!

Get 1:1 Help Now