sastowe
14 years agoSuper Contributor
click working in one grid but not another
I have a procedure below. I use to click on the desired cell in a Janus GridEX (ActiveX version in VB6). The procedure takes a tShift contant and gives that to the click.
I have a form that has a bunch of grids on it. This code works great on one of the grids. But another of the grids of the exact same type, it will do the click but does not seem to use the tShift parameter of the click. I can see in the debugger that the skCtrl value is the same as the tShift value I am using.
I have another procedure that calls this procedure in succession which simulates a sequence of clicks with and without keys pressed. It works great for one of my grids, but not another of the same type on the same form. Any ideas what might be going on?
Thanks
Sub ClickCellEx(grid, rowIndex, sColCaption, tShift)
Dim SplitNo, SplitCount
' Checks whether the grid contains the specified row
If rowIndex < 1 Or rowIndex > grid.RowCount Then
Log.Error "Row index " & rowIndex & " is out of bounds 1 ... " & grid.RowCount & "."
Exit Sub
End If
' Checks whether the grid contains the specified column
'If Not aqObject.GetVarType(column) = 8 Then
If Not aqObject.GetVarType(column) = varOleStr Then
If column < 0 Or column > grid.Columns.Count Then
Log.Error "Column index " & column & " is out of bounds 1 ... " & grid.Columns.Count & "."
Exit Sub
End If
Else
Err.Clear
On Error Resume Next
Set col = grid.Columns(column)
If Err.Number <> 0 Then
Log.Error Err.Description
Exit Sub
End If
End If
lColIndex = getColByIndex(grid, sColCaption)
' Find the cell left and cell top, abnd cell height
grid.Row = rowIndex
grid.Col = lColIndex
lLeft = grid.CellLeft()
lTop = grid.CellTop()
lHeight = grid.CellHeight()
' Calculates the horizontal coordinates of the cell (in VB twips)
'xTwips = grid.Columns(column).Left + (grid.Columns(column).Width / 2)
xTwips = lLeft+ (grid.Columns(lColIndex).Width / 2)
' Converts twips to pixels
x = CLng(TwipsToPixelsX(xTwips))
' Calculates the vertical coordinates of the cell (in VB twips)
'yTwips = grid.RowTop(rowIndexV) + grid.RowHeight / 2
yTwips = lTop + lHeight / 2
' Converts twips to pixels
y = CLng(TwipsToPixelsY(yTwips))
' Clicks the specified cell
grid.Click x, y, tShift
End Sub '' ClickCellEx
I have a form that has a bunch of grids on it. This code works great on one of the grids. But another of the grids of the exact same type, it will do the click but does not seem to use the tShift parameter of the click. I can see in the debugger that the skCtrl value is the same as the tShift value I am using.
I have another procedure that calls this procedure in succession which simulates a sequence of clicks with and without keys pressed. It works great for one of my grids, but not another of the same type on the same form. Any ideas what might be going on?
Thanks
Sub ClickCellEx(grid, rowIndex, sColCaption, tShift)
Dim SplitNo, SplitCount
' Checks whether the grid contains the specified row
If rowIndex < 1 Or rowIndex > grid.RowCount Then
Log.Error "Row index " & rowIndex & " is out of bounds 1 ... " & grid.RowCount & "."
Exit Sub
End If
' Checks whether the grid contains the specified column
'If Not aqObject.GetVarType(column) = 8 Then
If Not aqObject.GetVarType(column) = varOleStr Then
If column < 0 Or column > grid.Columns.Count Then
Log.Error "Column index " & column & " is out of bounds 1 ... " & grid.Columns.Count & "."
Exit Sub
End If
Else
Err.Clear
On Error Resume Next
Set col = grid.Columns(column)
If Err.Number <> 0 Then
Log.Error Err.Description
Exit Sub
End If
End If
lColIndex = getColByIndex(grid, sColCaption)
' Find the cell left and cell top, abnd cell height
grid.Row = rowIndex
grid.Col = lColIndex
lLeft = grid.CellLeft()
lTop = grid.CellTop()
lHeight = grid.CellHeight()
' Calculates the horizontal coordinates of the cell (in VB twips)
'xTwips = grid.Columns(column).Left + (grid.Columns(column).Width / 2)
xTwips = lLeft+ (grid.Columns(lColIndex).Width / 2)
' Converts twips to pixels
x = CLng(TwipsToPixelsX(xTwips))
' Calculates the vertical coordinates of the cell (in VB twips)
'yTwips = grid.RowTop(rowIndexV) + grid.RowHeight / 2
yTwips = lTop + lHeight / 2
' Converts twips to pixels
y = CLng(TwipsToPixelsY(yTwips))
' Clicks the specified cell
grid.Click x, y, tShift
End Sub '' ClickCellEx