Print Page | Close Window

Cell Clicked

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=2842
Printed Date: 21 November 2024 at 1:08pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Cell Clicked
Posted By: Maui
Subject: Cell Clicked
Date Posted: 04 September 2005 at 9:00am

Hi,

Sorry if this sounds lazy of me but I havent used these controls in about 6 months.

I need to respond to a cell click in the report control but I can't seem to be able to find any events such as RowClicked or CellClicked where I could easily place my code.

Can anyone help me out with what I am sure is a simple question before I go and waste half a day batteling to find an answer.

Thank you.

PS Too bad we dont have a Knowledgebase so that samples like this could be added to it for everyones benifit.




Replies:
Posted By: nighthawk
Date Posted: 04 September 2005 at 4:09pm
You might try using the MouseDown event.  The following code is from the ReportControl sample project:

Private Sub wndReportControl_MouseDown(Button As Integer, Shift As Integer, X As Long, Y As Long)
    Dim hitColumn As ReportColumn
    Dim hitRow As ReportRow
    Dim hitItem As ReportRecordItem
   
    'The MouseDown event is being used to illustrate how the HitTest method can be used.  The HitTest method does not have
    'to be used with a mouse event, it can be used to test any X and Y coordinate on the screen to see if the ReportControl
    'occupies these pixes and what part of the ReportControl is at the specified pixel (Group Box, Row, Item, etc).
    'If it is dertermined that a ReportControl component is at the X and Y coordinates, the HitTest method can return a
    'reference to that component (Column, Row, Record, Item, etc...).
       
    'Determines which part of the ReportControl the mouse was positioned over when clicked.
    Select Case wndReportControl.HitTest(X, Y).ht
        'If MouseDown while positioned anywhere over the Group Box (Even over Column Headers in Group Box)
        Case xtpHitTestGroupBox:
            Debug.Print "MouseDown in Group Box"
        'If MouseDown while positioned anywhere over the ColumnHeader area.  This does NOT include
        'column header in the Group Box
        Case xtpHitTestHeader:
            Debug.Print "MouseDown in Column Header Area (Not in Group Box)"
        'If MouseDown while positioned over the Report Area, this would includ, rows, columns, items, goup rows, expand buttons
        Case xtpHitTestReportArea:
            Debug.Print "MouseDown in Report Area"
        'This case will never happen, Unknown is returned when HitTest is called and the mouse is positioned
        'over an area outside of the report control
        Case xtpHitTestUnknown:
            Debug.Print "Mouse is in an Unknown Area"
    End Select
   
    'Returns a reference to the column cliked
    'Determines which column the mouse is positioned over on MouseDown, this will also be executed
    'if the column header in the Group By box is clicked.  This will be true if any item in the column
    'is clicked, not just column headers.
    Set hitColumn = wndReportControl.HitTest(X, Y).Column
    If Not hitColumn Is Nothing Then
        Debug.Print "MouseDown on Column header: " & hitColumn.Caption
    End If
   
    'Returns a reference to the row clicked
    'Determines which row the mouse was positioned over on mousedown.
    Set hitRow = wndReportControl.HitTest(X, Y).Row
    If Not hitRow Is Nothing Then
        If hitRow.GroupRow Then
            Debug.Print "MouseDown on GroupRow"
        Else
            Debug.Print "MouseDown on Row # " & hitRow.Index
        End If
    End If
   
    'Returns a reference to the item clicked
    'Determines which row the mouse was positioned over on mousedown.
    Set hitItem = wndReportControl.HitTest(X, Y).Item
    If Not hitItem Is Nothing Then
        If Not wndReportControl.PreviewMode Then
            Debug.Print "MouseDown on Item: " & hitItem.Value & " in column: " & hitColumn.Caption
        ElseIf Not (hitRow.Record.PreviewText = "") Then
            Debug.Print "MouseDown on PreviewText"
        End If
    End If
End Sub



Posted By: Maui
Date Posted: 06 September 2005 at 5:08am
Thank You.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net