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.
I want know how can get the current cell in a worksheet.
I have this code:
Private Sub frmScatterPlot_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
' Initialize the flag to false.
nonNumberEntered = False
If e.Modifiers = Keys.Control AndAlso e.KeyCode = Keys.A Then
If rgDataGatheringControlContainer.Name = Me.ActiveControl.Name Then
rgDataGatheringControl.SelectRange(2, 1, 32, 2)
End If
nonNumberEntered = True
Exit Sub
End If
If e.KeyCode = Keys.Escape Then
If rgDataGatheringControlContainer.Name = Me.ActiveControl.Name Then
With rgDataGatheringControl
.SelectionMode = ReoGridSelectionMode.None
.SelectionMode = ReoGridSelectionMode.Range
.FocusPos = New ReoGridPos(2, 1)
End With
End If
End If
End Sub
I have static pos but i want to get the current pos and check to make sure it is inside my range that is writable.
Shane
Offline
Did you mean the current editing cell? There is a method to get the editing cell.
Dim pos = worksheet.GetEditingCell()
If you want get the selected cell, the property FocusPos is used to do that.
Last edited by Jingwood (2014-12-11 09:14:30)
Offline
Jing,
I mean like you would with CellEventArgs, you can get the e.row and e.column, that is what i am looking for.
I want be able to check the row and column, so i can move if they enter into readonly cell it will put in the first on column editable column.. i am looking this also when i take tab and enter keys so it only stay in that area an no were else.
In that instance i want to get current position, so when press CTRL+A and if press ESC it will go back last position before you pressed CTRL+A. That is one reason why i want to get Row and column position.
Shane
Offline
I guess you could use the FocusPosChanged event, and its property Position. The below code keeps focus cell always at (0,0) position.
AddHandler sheet.FocusPosChanged, Sub(s, e)
Debug.WriteLine(e.Position.ToAddress())
If (e.Position.Row > 0 OrElse e.Position.Col > 0) Then
sheet.FocusPos = New ReoGridPos(0, 0)
End If
End Sub
And for Ctrl+A, I recommend that to prevent Ctrl+A rather than put the position back to previous position, the below code will prevent the Ctrl+A:
AddHandler sheet.BeforeCellKeyDown, Sub(s, e)
e.IsCancelled = (e.KeyCode = Keys.Control Or Keys.A)
End Sub
Last edited by Jingwood (2014-12-11 13:53:57)
Offline
thank you,
I am using this code in another place.
AddHandler sheet.BeforeCellKeyDown, Sub(s, e)
e.IsCancelled = (e.KeyCode = Keys.Control Or Keys.A)
End Sub
ok.. i see what you are talking about..
Shane
Offline
OK Let me know if you still meet this problem.
Offline