DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links