Author Topic: datagridview right click get row/column values  (Read 15626 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: datagridview right click get row/column values
« Reply #15 on: November 12, 2013, 01:22:18 PM »
John, your Zoom method is calling itself, thereby it is getting into an unending loop which is causing the stack overflow.

jcoon

  • Newt
  • Posts: 157
Re: datagridview right click get row/column values
« Reply #16 on: November 13, 2013, 12:05:15 PM »
Jeff_M,

Thanks.  Sorry I didn't respond,  I had a few rush items yesterday, Hopefully I can get time to correct that.

I think I know what's wrong with Vb dot net.....It makes people like me think......hey that would be nice to add.........fast-forward two or three days and 100 viewed web pages later and I'm posting here for help...........maybe I should of kept the routines plan-jane just like in the past.   oh well it's fun to try or at least see what is available that I can actually understand.

John

Bert

  • Guest
Re: datagridview right click get row/column values
« Reply #17 on: November 18, 2013, 09:58:37 AM »
Keep challenging yerself !

But like Jeff_M said, yer looping your code :

In my example its 'ZoomWindow' that calls 'Zoom' with a specific set of parameters.
Code - vb.net: [Select]
  1.     Public Shared Sub ZoomWindow(_pMin As Point3d, _pMax As Point3d)
  2.         '' Zoom to a window
  3.         Zoom(_pMin, _pMax, New Point3d(), 1)
  4.     End Sub
  5.  

jcoon

  • Newt
  • Posts: 157
Re: datagridview right click get row/column values
« Reply #18 on: December 02, 2013, 03:14:27 PM »
With a little time off for the holidays I was able to find time to work on this for a few days, with help from Fixo, Bert and through-the-interface I was able to get a working sample for now. currently working on test for button that cycles thru each row and does the same function as the right click but it needs a check for empty row value and highlight current row as visual for user.

thanks to all for sample & help
john


Private Sub DataGridView2_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles DataGridView2.MouseDown
        Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor()
        Dim db As Database = HostApplicationServices.WorkingDatabase
        Dim civilDoc As CivilDocument = CivilApplication.ActiveDocument
        Dim acaddoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument

        If e.Button = Forms.MouseButtons.Right Then
            Dim hi As DataGridView.HitTestInfo = Me.DataGridView2.HitTest(e.Location.X, e.Location.Y)
            MsgBox(Me.DataGridView2(6, hi.RowIndex).Value.ToString() + vbLf + Me.DataGridView2(7, hi.RowIndex).Value.ToString())

            Dim passcell6 As Double
            Dim passcell7 As Double
            passcell6 = (Me.DataGridView2(6, hi.RowIndex).Value.ToString())
            passcell7 = (Me.DataGridView2(7, hi.RowIndex).Value.ToString())

            Dim zoomcorner1(0 To 1) As Double
            Dim zoomcorner2(0 To 1) As Double
            zoomcorner1(0) = passcell6 + 100
            zoomcorner1(1) = passcell7 + 100
            zoomcorner2(0) = passcell6 - 100
            zoomcorner2(1) = passcell7 - 100
            'x,y, location from grid
            Dim _pMin As Autodesk.AutoCAD.Geometry.Point2d = New Autodesk.AutoCAD.Geometry.Point2d(zoomcorner1)
            Dim _pMax As Autodesk.AutoCAD.Geometry.Point2d = New Autodesk.AutoCAD.Geometry.Point2d(zoomcorner2)
            Dim Min As Point2d
            Dim Max As Point2d
            Min = _pMin
            Max = _pMax
            ZoomWin(ed, Min, Max, True)
        End If
    End Sub

Private Shared Sub ZoomWin(ByVal ed As Editor, ByVal Min As Point2d, ByVal Max As Point2d, ByVal quietly As Boolean)
        Dim lower As String = Min.ToString.Substring(1, (Min.ToString.Length - 2))
        Dim upper As String = Max.ToString.Substring(1, (Max.ToString.Length - 2))
        Dim cmd As String = ("_.ZOOM _W " _
                    + (lower + (" " _
                    + (upper + " "))))
        If quietly Then
            ' Get the old value of NOMUTT
            Dim nomutt As Object = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("NOMUTT")
            ' Add the string to reset NOMUTT afterwards
            cmd = (cmd + ("_NOMUTT " _
                        + (nomutt.ToString + " ")))
            ' Set NOMUTT to 1, reducing cmd-line noise
            Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("NOMUTT", 1)
        End If
        ' Send the command(s)
        ed.Document.SendStringToExecute(cmd, True, False, Not quietly)
    End Sub