I want (okay, the *user* wants) to make cells un-editable until they first hit return in that cell.
So, I have an unbound, readonly grid. I''m using the CurrentCellKeyDown event to test for the enter key, and change the cell''s readonly attribute using this code:
Dim gsi As New GridStyleInfo()
gsi.ReadOnly = False
Me.GridControl1.IgnoreReadOnly = True
However, this code doesn''t work if I set the grid''s ActivateCurrentCellBehavior to GridCellActivateAction.SelectAll (presumably because the edit control -- a textbox -- is getting the keystrokes instead of the current cell.
So my questions are:
1) Is there a way to process keystroke events from within the textbox editing control?
2) If I set the grid to GridCellActivateAction.None, how can I select all the existing text in the cell after I''ve change the readonly attribute? I tried the following code that I dredged from a forum message, but I don''t really understand it, and it doesn''t work anyway:
3) Is there an altogether better technique for providing the same user-experience that you would suggest?
ADAdministrator Syncfusion Team July 28, 2004 12:24 AM
Here is one way I think you can get the Enter key to toggle readonly and select all the text when the cell is toggled to not readonly.
Set the ActivateCurrentCellBehavior to none. Handl grid.KeyDown and there toggle the readonly and select the text. Also handle CurrentCellMoved to set the ReadOnly back to true after the cell has finished editing.
Here is a little sample.
ADAdministrator Syncfusion Team July 28, 2004 11:32 AM
Thank-you very much! That was just the ticket. It was pretty close to what I already had, but I wasn''t using the CurrentCell.BeginEdit() before attempting to access the GridTextBoxControl.
Anyways, thanks again, and big kudos to you and Syncfusion for providing this stellar support venue.