ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

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.

https://github.com/unvell/ReoGrid/issues

#1 2014-08-29 00:02:36

asparatu
Member
Registered: 2014-08-20
Posts: 196

Select Range not working

How can override the keydown event for the Ctrl+A?

This code that overrides the control+A, but when it executes it selects the whole range of the control and not just the range i want.
Is there another way to do this or is that correct way?

Thank you,
Shane

 ' Initialize the flag to false.
        nonNumberEntered = False

        Dim range As ReoGridRange = New ReoGridRange(2, 1, 32, 2)

        If e.Modifiers = Keys.Control AndAlso e.KeyCode = Keys.A Then
            If rgDataGathering.Name = Me.ActiveControl.Name Then
                rgDataGathering.SelectRange(range)
            End If
            nonNumberEntered = False
            Exit Sub
        End If

Last edited by asparatu (2014-08-31 01:14:51)

Offline

#2 2014-09-05 02:30:33

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Select Range not working

In 0.8.7 Ctrl+A can be prevented by BeforeCellKeyDown event:
http://reogrid.net/v0-8-7/handle-keyboard-event/

C#

var sheet = grid.CurrentWorksheet;

sheet.BeforeCellKeyDown += (ss, ee) => ee.IsCancelled = (ee.KeyCode == (Keys.Control | Keys.A));

VB

Dim sheet = grid.CurrentWorksheet

AddHandler sheet.BeforeCellKeyDown, _
    Sub(ss, ee)
        ee.IsCancelled = ee.KeyCode = (Keys.Control Or Keys.A)
    End Sub

Last edited by Jingwood (2014-09-05 02:35:59)

Offline

#3 2014-09-09 02:01:21

asparatu
Member
Registered: 2014-08-20
Posts: 196

Re: Select Range not working

Thank you, I will use the new version of ReoGrid and use the code you gave me.

I, also, assume you put this in the load event?

I also see that cancels the keypress for control key or A key, because it has an OR logic. I would assume that it would have to be ANDALSO Logic, so check to for the combination of both keys and just not one?

Shane

Last edited by asparatu (2014-09-09 02:10:00)

Offline

#4 2014-09-09 10:23:37

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Select Range not working

Yes it is in Load event. I think OR keyword is the combination, it's binary or, not logical or.

Offline

Board footer

Powered by FluxBB