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 2016-04-12 03:54:00

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

Check for Esc key in aftercelledit event

Hello Jing,
  Is there check if the esc key is pressed in aftercell event? since i am handling the data.. when i press the esc key it takes and erase the data and i want to cancel it.
Shane

Offline

#2 2016-04-12 07:54:47

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

Re: Check for Esc key in aftercelledit event

When the EndReason property of event argument is Cancel that means user pressed Esc key, but what do you mean that 'cancel it'? the Edit operation is finished, you can't cancel anything.

Last edited by Jingwood (2016-04-12 08:15:35)

Offline

#3 2016-04-12 08:11:51

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

Re: Check for Esc key in aftercelledit event

Hello Jing,
   I want to managed the Esc key event.. In the code there if the data is nothing or not a double it, just sets the data to nothing.. and finishes normally. I did have set to cancel, but changed it because when pressed backspace and enter it didnt delete it, not when does if delete and press esc it deletes it. what i want to do is put a condition to check if the esc was pressed and it would do normalfinish and not set the data to nothing.

 Private Sub AfterCellEditIsNumeric(sender As Object, e As CellAfterEditEventArgs)
        Dim val As Double = 0

        If e.NewData Is Nothing OrElse Not Double.TryParse(e.NewData.ToString(), val) Then
           e.NewData = Nothing
            e.EndReason = EndEditReason.NormalFinish
        Else
            e.NewData = val
        End If
    End Sub

Offline

#4 2016-04-12 08:19:29

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

Re: Check for Esc key in aftercelledit event

As your code

e.EndReason = EndEditReason.NormalFinish 

it should work.

Offline

#5 2016-04-12 08:25:51

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

Re: Check for Esc key in aftercelledit event

Hello Jing,
It works, but when use this way it removes the e.newdata.. when esc is pressed, i dont want to do that.. i want be able to manage it. like in keypress event.

if i have.. 123 in the cell and press backspace it erase it, when press esc does not revert to the 123 but sets it to nothing.

Shane

If use EndEditReason.NormalFinish the enter button works, if use EndEditReason.Cancel the esc works, so i dont put anything in it, works right

 Private Sub AfterCellEditIsNumeric(sender As Object, e As CellAfterEditEventArgs)
        Dim val As Double = 0

        If e.NewData Is Nothing Then
            e.NewData = Nothing
            e.EndReason = EndEditReason.Cancel
        ElseIf e.NewData Is String.Empty Then

        ElseIf Not Double.TryParse(e.NewData.ToString(), val) Then
            e.NewData = Nothing
            e.EndReason = EndEditReason.Cancel
        Else
            e.NewData = val
        End If
    End Sub

Last edited by asparatu (2016-04-12 08:48:31)

Offline

#6 2016-04-12 11:29:17

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

Re: Check for Esc key in aftercelledit event

Hi Shane, is this problem get solved? I can't see from you reply.

Last edited by Jingwood (2016-04-12 12:20:57)

Offline

#7 2016-04-12 15:26:53

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

Re: Check for Esc key in aftercelledit event

Hello Jing,
   No... sorry.. I got to work by just work right by not handling the endedit on the newdata string
Shane

Offline

#8 2016-04-12 16:04:30

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

Re: Check for Esc key in aftercelledit event

What's your problem now?

Offline

#9 2016-04-13 01:26:56

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

Re: Check for Esc key in aftercelledit event

Hello Jing,
  there is not problem now.. i was just telling you.. I was able to get it working correctly without trying to handling the endreason, when the newdata is string.empty. sorry,, still didnt explain clearly enough of how i get to work right.

Shane

Offline

#10 2016-04-13 01:42:52

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

Re: Check for Esc key in aftercelledit event

Glad to hear that!

Offline

Board footer

Powered by FluxBB