SOLVED:HitTest
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=17282
Printed Date: 03 November 2025 at 4:06am Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: SOLVED:HitTest
Posted By: JamGodz
Subject: SOLVED:HitTest
Date Posted: 19 September 2010 at 7:52pm
Hi Everyone! or Aaron
why is it the hitItem in VirtualMode doesn't display a value/caption.
Dim hitItem As ReportRecordItem '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
|
Replies:
Posted By: SuperMario
Date Posted: 20 September 2010 at 3:59pm
|
In VM rows don't really have data, the data is drawn in using the BeforeDrawRow event. So you would need to use the column\row indexes to calculate which data this is.
|
Posted By: JamGodz
Date Posted: 20 September 2010 at 8:51pm
Hi SuperMario! Good Day!
thanks you for your reply... is there any other way to get the hitTest in VM? or any workaround?
please...
thanks?
|
Posted By: Aaron
Date Posted: 21 September 2010 at 3:57am
JamGodz wrote:
Hi SuperMario! Good Day!
thanks you for your reply... is there any other way to get the hitTest in VM? or any workaround? please...
thanks?
|
Hi,
How do you show data in ReportControl Virtualmode? I guess you have somekind of array, right? If you have an array you are able to retrieve the data by accessing the array:
Dim hitRow As XtremeReportControl.ReportRow Dim hitColumn As XtremeReportControl.ReportColumn
Set hitRow = wndReportControl.HitTest(x, y).Row
Set hitColumn = wndReportControl.HitTest(x, y).Column
If Not hitColumn Is Nothing and not HitRow is nothing Then Debug.Print "MouseDown on Item: " & myArray(hitColumn.ItemIndex, hitRow.Index) End If
If this doesn't help please upload sample project and add some info to what you need 
To SuperMario: Would it be possible to return Item.Caption as well? HitTest is already returning ReportItem.Index or do you calculate index on the fly?
Thanks
------------- Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0
Zero replies is not an option....
|
Posted By: JamGodz
Date Posted: 21 September 2010 at 8:08am
Hi Aaron!
Im using the code below to retrieve data in database...:
Private Const COLUMN_APHC = 0
Private Const COLUMN_PLTRNAME = 1
Private Const COLUMN_HDANAME = 2
Private Const COLUMN_LKG = 3
Private Const COLUMN_NETCANE = 4
Private Const COLUMN_ESTIMATED = 5
Private Const COLUMN_PROGRESS = 6
Private Const COLUMN_ICON_STATUS = 7
Dim sSplit As Variant
Private Sub Form_Load()
sSplit = Array("APHCODE", "PLTR_NAME", "HDA_NAME", "T_LKG", "T_NET_CANE", "ESTIMATED", "PROGRESS")
rs.Open SQLParser.SQLStatement, ConnectTo.InternalConn, adOpenStatic, adLockOptimistic
CustomizeRepCtrl
If rs.RecordCount > 0 Then rs.MoveFirst
With wndList
.SetVirtualMode rs.RecordCount
.Populate
.Redraw
End With
End Sub
Private Sub wndList_BeforeDrawRow(ByVal Row As
XtremeReportControl.IReportRow, ByVal Item As
XtremeReportControl.IReportRecordItem, ByVal Metrics As
XtremeReportControl.IReportRecordItemMetrics)
If Row.Index < rs.RecordCount Then
rs.AbsolutePosition = Row.Index + 1: rs.Move 0
Select Case Item.Index
Case COLUMN_APHC, COLUMN_PLTRNAME, COLUMN_HDANAME, COLUMN_LKG,
Metrics.Text = rs.Fields(sSplit(Item.Index)).Value & ""
End If
End Select
End If
End Sub
Private Sub CustomizeRepCtrl()
Dim Column As ReportColumn
Set Column = wndList.Columns.Add(COLUMN_ICON_STATUS, "ICONSTATUS", 18, False)
Column.Editable = False
Column.Icon = COLUMN_BLACK_ICON
Set Column = wndList.Columns.Add(COLUMN_APHC, "APHCODE", 100, True)
Column.Editable = False
Set Column = wndList.Columns.Add(COLUMN_PLTRNAME, "Planter Name", 400, True)
Column.Editable = False
Set Column = wndList.Columns.Add(COLUMN_HDANAME, "HDA Name", 200, True)
Column.Editable = False
Set Column = wndList.Columns.Add(COLUMN_LKG, "LKG", 70, True)
Column.Editable = False
Set Column = wndList.Columns.Add(COLUMN_NETCANE, "NET CANE", 70, True)
Column.Editable = False
Set Column = wndList.Columns.Add(COLUMN_ESTIMATED, "EST. NET CANE", 100, True)
Column.Editable = True
Column.EditOptions.SelectTextOnEdit = True
With wndList
.PaintManager.ColumnStyle = xtpColumnOffice2007
.EnableMarkup = True
.PaintManager.DrawGridForEmptySpace = True
.PaintManager.VerticalGridStyle = xtpGridSmallDots
.PaintManager.HorizontalGridStyle = xtpGridSmallDots
.SetCustomDraw xtpCustomBeforeDrawRow
.SetVirtualMode 0
End With
End Sub
Private Sub wndList_BeginEdit(ByVal Row As
XtremeReportControl.IReportRow, ByVal Column As
XtremeReportControl.IReportColumn, ByVal Item As
XtremeReportControl.IReportRecordItem)
Dim i As Integer
rs.AbsolutePosition = (Row.Index + 1): rs.Move 0
For i = 0 To UBound(sSplit())
ReDim Preserve strItemVal(0 To i)
strItemVal(i) = rs.Fields(sSplit(i)).Value & ""
Next i
End Sub
Please let me know if have mistaken something... thanks
|
Posted By: Aaron
Date Posted: 21 September 2010 at 8:41am
|
Hi,
Something like:
Private Sub wndReportControl_MouseDown(Button As Integer, Shift As Integer, x As Long, y As Long)
Dim hitRow As XtremeReportControl.ReportRow Dim hitColumn As XtremeReportControl.ReportColumn
On Error GoTo myerror
Set hitRow = wndReportControl.HitTest(x, y).Row Set hitColumn = wndReportControl.HitTest(x, y).Column rs.AbsolutePosition = hitRow.Index rs.Move 0 If Not hitRow Is Nothing Then Debug.Print "MouseDown on Item: " & rs.Fields(hitColumn.ItemIndex).Value End If myerror: If Err.Number > 0 Then 'do something with it !!! End If
You will get value of selected "cell" from the recordset itself.
------------- Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0
Zero replies is not an option....
|
Posted By: JamGodz
Date Posted: 21 September 2010 at 10:13am
|
thanks... another problem solved!
|
|