using keyboard shortcuts in the grid
Hi,
I have attached a very small sample application with just 4 cells from which I have the following question.
1) I do not want cells 3 and 4 to be editable, so I cancel the currentcellstartedit event. If I use "Shift+Del" key on cell3, it does not edit, however on cell4 it removes the contents. My guess is this due to cell4 being a formulacell? Is there a place where I can find a list of all keyboard shortcuts used in the grid? Is there a property to disable *all* shortcuts, or do I have to check for the keypress event and add in handling myself?
2) In the sample, I do not want the user to be able to edit the 3rd cell. I cancel the CurrentCellStartEditing event if the third cell was selected. However, if the cell is activated and I press the "Delete" key, then select any other cell in the grid, it becomes apparent that the CellValidating and CellAcceptedChanges events still ran. However, if instead of hitting the Delete key I had typed in a value, they would not run which is what I want. Would you be able to explain what is happening in this scenario?
Thanks in advance.
Syncfusion.zip
I have attached a very small sample application with just 4 cells from which I have the following question.
1) I do not want cells 3 and 4 to be editable, so I cancel the currentcellstartedit event. If I use "Shift+Del" key on cell3, it does not edit, however on cell4 it removes the contents. My guess is this due to cell4 being a formulacell? Is there a place where I can find a list of all keyboard shortcuts used in the grid? Is there a property to disable *all* shortcuts, or do I have to check for the keypress event and add in handling myself?
2) In the sample, I do not want the user to be able to edit the 3rd cell. I cancel the CurrentCellStartEditing event if the third cell was selected. However, if the cell is activated and I press the "Delete" key, then select any other cell in the grid, it becomes apparent that the CellValidating and CellAcceptedChanges events still ran. However, if instead of hitting the Delete key I had typed in a value, they would not run which is what I want. Would you be able to explain what is happening in this scenario?
Thanks in advance.
Syncfusion.zip
SIGN IN To post a reply.
4 Replies
RA
Rajagopal
Syncfusion Team
August 21, 2007 06:55 PM UTC
Hi Omar,
Thanks for your interest in Syncfusion Products.
1. To make the cells 3 and 4 in the grid non-editable, you need to set the readonly property to true. You may do this by directly accessing the GridStyleInfo object of the concerned cell or handle the QueryCellInfo event of the grid and set the readonly for the cells there. In addition, if you want to cancel any key events inside a cell, then you could handle the CurrrentCellKeyDown event of the grid and set e.Handled to true.
2. In the sample setting the readonly to true for the 3rd cell should handle this problem. Cancelling the editing for the cells through the CurrentCellStartEditing event will allow the cell to recieve the key events like delete, this results in the CurrentCell.IsModified flag to true causing the CurrentCellValidating and CurrentCellAcceptedChanges to trigger in your scenario.
Please refer the modified sample below that works fine
Syncfusion1.zip
Let me know if you have any other questions.
Have a nice time.
Regards,
Rajagopal
Thanks for your interest in Syncfusion Products.
1. To make the cells 3 and 4 in the grid non-editable, you need to set the readonly property to true. You may do this by directly accessing the GridStyleInfo object of the concerned cell or handle the QueryCellInfo event of the grid and set the readonly for the cells there. In addition, if you want to cancel any key events inside a cell, then you could handle the CurrrentCellKeyDown event of the grid and set e.Handled to true.
2. In the sample setting the readonly to true for the 3rd cell should handle this problem. Cancelling the editing for the cells through the CurrentCellStartEditing event will allow the cell to recieve the key events like delete, this results in the CurrentCell.IsModified flag to true causing the CurrentCellValidating and CurrentCellAcceptedChanges to trigger in your scenario.
Please refer the modified sample below that works fine
Syncfusion1.zip
Let me know if you have any other questions.
Have a nice time.
Regards,
Rajagopal
OM
Omar
August 22, 2007 01:59 PM UTC
I am aware of the Read-only property, however, I do not want to use it because I am displaying a custom error message depending on why the cell is not editable.
1) I still do not understand why pressing shift+del on cell4 deletes its contents but that does not happen on cell3.
2) In Cell3, typing in a numeric value did not change the CurrentCell.IsModified but pressing the Delete key did. Which other keys will result in such behavior? Is such behavior expected?
Thanks.
>Hi Omar,
Thanks for your interest in Syncfusion Products.
1. To make the cells 3 and 4 in the grid non-editable, you need to set the readonly property to true. You may do this by directly accessing the GridStyleInfo object of the concerned cell or handle the QueryCellInfo event of the grid and set the readonly for the cells there. In addition, if you want to cancel any key events inside a cell, then you could handle the CurrrentCellKeyDown event of the grid and set e.Handled to true.
2. In the sample setting the readonly to true for the 3rd cell should handle this problem. Cancelling the editing for the cells through the CurrentCellStartEditing event will allow the cell to recieve the key events like delete, this results in the CurrentCell.IsModified flag to true causing the CurrentCellValidating and CurrentCellAcceptedChanges to trigger in your scenario.
Please refer the modified sample below that works fine
Syncfusion1.zip
Let me know if you have any other questions.
Have a nice time.
Regards,
Rajagopal
1) I still do not understand why pressing shift+del on cell4 deletes its contents but that does not happen on cell3.
2) In Cell3, typing in a numeric value did not change the CurrentCell.IsModified but pressing the Delete key did. Which other keys will result in such behavior? Is such behavior expected?
Thanks.
>Hi Omar,
Thanks for your interest in Syncfusion Products.
1. To make the cells 3 and 4 in the grid non-editable, you need to set the readonly property to true. You may do this by directly accessing the GridStyleInfo object of the concerned cell or handle the QueryCellInfo event of the grid and set the readonly for the cells there. In addition, if you want to cancel any key events inside a cell, then you could handle the CurrrentCellKeyDown event of the grid and set e.Handled to true.
2. In the sample setting the readonly to true for the 3rd cell should handle this problem. Cancelling the editing for the cells through the CurrentCellStartEditing event will allow the cell to recieve the key events like delete, this results in the CurrentCell.IsModified flag to true causing the CurrentCellValidating and CurrentCellAcceptedChanges to trigger in your scenario.
Please refer the modified sample below that works fine
Syncfusion1.zip
Let me know if you have any other questions.
Have a nice time.
Regards,
Rajagopal
OM
Omar
August 22, 2007 03:13 PM UTC
I realize that, oddly, the CurrentCellStartEditing event is raised even when a cell is set to ReadOnly.
However, I still don't know the answer to the last 2 questions that I asked.
Thanks.
However, I still don't know the answer to the last 2 questions that I asked.
Thanks.
AD
Administrator
Syncfusion Team
January 4, 2008 04:40 PM UTC
Hi Omar,
Sorry for the delay in getting back to you.
Issue 1 : Using Shift+del on cell4 deletes its contents but that does not happen on cell3.
I am not able to reproduce this issue in Syncfusion Essential Studio 2008 Volume 1 Final version (6.1.0.34). Please tell me the Essential studio version you are using.
Issue 2 : if the cell is activated and I press the "Delete" key, then select any other cell in the grid, it becomes apparent that the CellValidating and CellAcceptedChanges events still ran.
This issue can be resolved by setting GridControl1.CurrentCell.IsModified = False in CellValidating and CellAcceptedChanges events as follows.
[VB]
Private Sub GridControl1_CurrentCellValidating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles GridControl1.CurrentCellValidating
If GridControl1.CurrentCell.ColIndex = 3 Or GridControl1.CurrentCell.ColIndex = 4 Then
GridControl1.CurrentCell.IsModified = False
Console.WriteLine("CurrentCellValidating")
End If
End Sub
Private Sub GridControl1_CurrentCellAcceptedChanges(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles GridControl1.CurrentCellAcceptedChanges
If GridControl1.CurrentCell.ColIndex = 3 Or GridControl1.CurrentCell.ColIndex = 4 Then
GridControl1.CurrentCell.IsModified = False
Console.WriteLine("CurrentCellAcceptedChanges")
End If
End Sub
Issue 3 : In Cell3, typing in a numeric value did not change the CurrentCell.IsModified but pressing the Delete key did.
I am able to reproduce this issue when displaying the status of CurrentCell.IsModified in CurrentCellKeyPress event as follows.
[VB]
Private Sub GridControl1_CurrentCellKeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles GridControl1.CurrentCellKeyPress
If GridControl1.CurrentCell.ColIndex = 3 Or GridControl1.CurrentCell.ColIndex = 4 Then
MessageBox.Show(GridControl1.CurrentCell.IsModified.ToString())
End If
End Sub
This is because the status of CurrentCell.IsModified will be displayed when numeric keys are pressed and not when DELETE key is pressed since CurrentCellKeyPress will not raise when DELETE key is pressed.
Issue 4 : CurrentCellStartEditing event is raised even when a cell is set to ReadOnly
I am not able to reproduce this issue in Syncfusion Essential Studio 2008 Volume 1 Final version (6.1.0.34).Please tell me the Essential studio version you are using.
Sample reference
Please refer the sample in the below location and let me know if you have any further questions.
http://websamples.syncfusion.com/samples/Grid.Windows/F67440/main.htm
Regards,
Jaya
Sorry for the delay in getting back to you.
Issue 1 : Using Shift+del on cell4 deletes its contents but that does not happen on cell3.
I am not able to reproduce this issue in Syncfusion Essential Studio 2008 Volume 1 Final version (6.1.0.34). Please tell me the Essential studio version you are using.
Issue 2 : if the cell is activated and I press the "Delete" key, then select any other cell in the grid, it becomes apparent that the CellValidating and CellAcceptedChanges events still ran.
This issue can be resolved by setting GridControl1.CurrentCell.IsModified = False in CellValidating and CellAcceptedChanges events as follows.
[VB]
Private Sub GridControl1_CurrentCellValidating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles GridControl1.CurrentCellValidating
If GridControl1.CurrentCell.ColIndex = 3 Or GridControl1.CurrentCell.ColIndex = 4 Then
GridControl1.CurrentCell.IsModified = False
Console.WriteLine("CurrentCellValidating")
End If
End Sub
Private Sub GridControl1_CurrentCellAcceptedChanges(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles GridControl1.CurrentCellAcceptedChanges
If GridControl1.CurrentCell.ColIndex = 3 Or GridControl1.CurrentCell.ColIndex = 4 Then
GridControl1.CurrentCell.IsModified = False
Console.WriteLine("CurrentCellAcceptedChanges")
End If
End Sub
Issue 3 : In Cell3, typing in a numeric value did not change the CurrentCell.IsModified but pressing the Delete key did.
I am able to reproduce this issue when displaying the status of CurrentCell.IsModified in CurrentCellKeyPress event as follows.
[VB]
Private Sub GridControl1_CurrentCellKeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles GridControl1.CurrentCellKeyPress
If GridControl1.CurrentCell.ColIndex = 3 Or GridControl1.CurrentCell.ColIndex = 4 Then
MessageBox.Show(GridControl1.CurrentCell.IsModified.ToString())
End If
End Sub
This is because the status of CurrentCell.IsModified will be displayed when numeric keys are pressed and not when DELETE key is pressed since CurrentCellKeyPress will not raise when DELETE key is pressed.
Issue 4 : CurrentCellStartEditing event is raised even when a cell is set to ReadOnly
I am not able to reproduce this issue in Syncfusion Essential Studio 2008 Volume 1 Final version (6.1.0.34).Please tell me the Essential studio version you are using.
Sample reference
Please refer the sample in the below location and let me know if you have any further questions.
http://websamples.syncfusion.com/samples/Grid.Windows/F67440/main.htm
Regards,
Jaya
SIGN IN To post a reply.
- 4 Replies
- 4 Participants
-
OM Omar
- Aug 17, 2007 10:17 PM UTC
- Jan 4, 2008 04:40 PM UTC