You are not logged in.
This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.
Pages: 1
Topic closed
Hello Jing,
I have this code that you give me while ago about testing CTRL+A key down event. As of the new version this does not work anymore or did you change something? From what i can see everything fires but nothing happens.. I test in another form that i took this code from that I know was working and it does not work anymore.
Event
AddHandler rgDataGatheringSheet.BeforeCellKeyDown, Sub(ss, ee)
ee.IsCancelled = ee.KeyCode = (Keys.Control Or Keys.A)
End Sub
Method
Private Function SelectAll(Optional e As KeyEventArgs = Nothing) As Boolean
Dim blnTemp As Boolean = False
If Me.ActiveControl.Name = Me.rgDataGatheringGrid.Name Then
With rgDataGatheringSheet
.SelectRange(validrange)
'or like this, but neither is working now..
If .ColumnCount = 4 Then
.SelectRange(1, (.ColumnCount - 1), (.RowCount - 1), (.ColumnCount - 1))
Else
.SelectRange(1, .ColumnCount, (.RowCount - 1), (.ColumnCount))
End If
blnTemp = True
End With
ElseIf Me.ActiveControl.Name = Me.rgResultsGrid.Name Then
With rgResultsSheet
.SelectRange(ReoGridRange.EntireRange)
End With
blnTemp = True
End If
Return blnTemp
End Function
Offline
Shane, is there any details of 'does not work', since I tested this code that everything works as expected.
AddHandler grid.CurrentWorksheet.BeforeCellKeyDown, Sub(ss, ee)
If (ee.KeyCode = (Keys.Control Or Keys.A)) Then
ee.IsCancelled = True
grid.CurrentWorksheet.SelectRange("C3:F5")
End If
End Sub
Do you want to cancel the default Ctrl+A and do a customize selection? The code above can do that. Where do you call the SelectAll method?
Offline
Hello Jing,
I think I know why it was not working right..I have test it tomorrow. The selectionmode is cell and range.
Shane
Offline
OK Good Luck!
Offline
Hello Jing,
the reason why it was not working was because I had grid.currentworksheet.selectionmode = cell and not grid.currentworksheet.selectionmode = range, but what i did is remove the grid.currentworksheet.selectionmode = cell and it worked fine after that..
the final code
Event Code
AddHandler grid.currentworksheet.BeforeCellKeyDown, Sub(ss, ee)
ee.IsCancelled = ee.KeyCode = (Keys.Control Or Keys.A)
End Sub
AddHandler rgDataGatheringSheet.BeforeSelectionRangeChange, Sub(s, e)
'checks to see the select flag is true
If m_blnSelectFlag Then Exit Sub
' Disable to select any cells outside validRanges
e.IsCancelled = Not validRange.Contains(e.SelectionStart) _
OrElse Not validRange.Contains(e.SelectionEnd)
End Sub
Method Code
Private Function SelectAll(Optional e As KeyEventArgs = Nothing) As Boolean
Dim blnTemp As Boolean = False
Select Case Me.ActiveControl.Name
Case rgDataGatheringGrid.Name
With rgDataGatheringSheet
.SelectRange(validRange)
End With
blnTemp = True
Case rgResultsSheet.Name
With rgResultsSheet
m_blnSelectFlag = True 'Check in the BeforeSelectionRangeChange, so it does not use validrange but total range of grid.
.SelectRange(ReoGridRange.EntireRange)
m_blnSelectFlag = False
End With
blnTemp = True
End Select
Return blnTemp
End Function
Update: Added the BeforeSelectionRangeChange Event
Last edited by asparatu (2015-09-16 04:32:09)
Offline
If SelectionMode is set to Cell, only single cell can be selected. Thanks for sharing the result.
Offline
Pages: 1
Topic closed