We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Toggle cell editing (readonly) based on user keystroke...

Thread ID:

Created:

Updated:

Platform:

Replies:

16939 Jul 28,2004 01:26 AM UTC Jul 28,2004 04:32 PM UTC Windows Forms 2
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On July 28, 2004 01:26 AM UTC

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 Me.GridControl1.SetCellInfo( _ Me.GridControl1.CurrentCell.RowIndex, _ Me.GridControl1.CurrentCell.ColIndex, _ gsi, _ Syncfusion.Styles.StyleModifyType.Changes) 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: CType(Me.GridControl1.CurrentCell.Renderer.Control, GridTextBoxControl).SelectAll() 3) Is there an altogether better technique for providing the same user-experience that you would suggest? Thanks, s.s.

Administrator [Syncfusion]
Replied On July 28, 2004 05:24 AM UTC

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.

Administrator [Syncfusion]
Replied On July 28, 2004 04:32 PM UTC

Clay - 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. s.s.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;