dbGrid MouseDown and X and Y


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: dbGrid MouseDown and X and Y

  1. #1
    George Guest

    dbGrid MouseDown and X and Y


    I have a dbGrid with a column the lists the number of Printers on a machine,
    I want to be able to right click on a cell in this column and be able to
    tell which column and row the mouse pointer is over. Right now I have to
    first click in the cell, then right click on it and am using .col. This
    works, but you can be anywhere on the dbgrid and it works. How do you use
    X and Y paramaters to tell where the mouse is, not where the currently selected
    cell is? Any help would be appreciated.

  2. #2
    Brent Guest

    Re: dbGrid MouseDown and X and Y


    George,
    Try this example:

    Private Sub DBGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single,
    Y As Single)

    Dim mbxPrompt As String
    Dim mbxStyle As Long
    Dim mbxTitle As String

    If Button = 2 Then

    mbxPrompt = "Mouse X Coord = " & X & vbCrLf
    mbxPrompt = mbxPrompt & "Mouse Y Coord = " & Y & vbCrLf
    mbxPrompt = mbxPrompt & "Mouse X Over Col = " & _
    DBGrid1.ColContaining(X) & vbCrLf
    mbxPrompt = mbxPrompt & "Mouse Y Over Row = " & _
    DBGrid1.RowContaining(Y)

    MsgBox mbxPrompt, mbxStyle, mbxTitle

    End If

    End Sub

    DBGrid1 is the name of your Grid Control.

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center