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. Image for the cookie policy date

Grid editing/selection/Keypress Issues

I want to use a Grid as a simple editor for Key-Value pairs. The grid has 2 columns. The first column is read-only and holds the key. The second col is editable and holds the value. Here is the behaviour I want: 1. When the grid is shown, I want the the first value (row 0, col 1) to be focused, in edit mode and all text "selected". 2. I want the Tab key to move me to the next value (row 1, col 1) and for it to be in edit mode and all text selected, etc. I have tried several things and run into some problems. For #1, I assumed that the following would work but it didn't: gridControl1.Focus(); gridControl1.CurrentCell.MoveTo(0,1); gridControl1.CurrentCell.BeginEdit(); The "editing cursor" fails to show up although apparently the current cell is set correctly because if I type a key then it replaces the text in the cell. Regarding #2, I have tried handling both "CurrentCellKeyPress" AND/OR "gridControl1_CurrentCellKeyDown" but neither one of them get called when the TAB key is pressed and the cell is in "IsEditing" mode. Other keys such as characters and BackSpace do fire the events, however. Any help would be appreciated. Blaine Anderson ComFrame Software

3 Replies

AD Administrator Syncfusion Team August 15, 2003 03:16 PM UTC

Blaine, Here is the code snippet that I think will do what you wanted to do. Please, make sure you enable the colunm before you set it to read only. this.gridControl1.EnterKeyBehavior = GridDirectionType.Down; this.gridControl1.ColStyles[1].Enabled = false; this.gridControl1.Model.Options.WrapCellBehavior = GridWrapCellBehavior.WrapRow; this.gridControl1.ColStyles[1].ReadOnly = true; this.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll; this.gridControl1.ForceCurrentCellMoveTo = true; this.gridControl1.CurrentCell.MoveTo(1,2); Regards, Priti

MM Michael Mann March 9, 2004 12:12 PM UTC

Hi, I have similar problems. I try to add a row, set the focus and begin editing in the current cell. my code snippet looks like this: private void button1_Click(object sender, System.EventArgs e) { int row = ++gridControl1.RowCount; gridControl1[row, 1].CellType = "TextBox"; gridControl1[row, 1].CellValue = "in edit"; this.gridControl1.EnterKeyBehavior = GridDirectionType.Down; this.gridControl1.Model.Options.WrapCellBehavior = GridWrapCellBehavior.WrapRow; this.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.ClickOnCell; this.gridControl1.ForceCurrentCellMoveTo = true; this.gridControl1.CurrentCell.MoveTo(row, 1); gridControl1.CurrentCell.BeginEdit(); } Can anyone provide a code snippet, that actually starts editing in the cell? Thanks in advance Michael Mann

AD Administrator Syncfusion Team March 9, 2004 01:25 PM UTC

Try setting gridControl1.Focus() as clicking a button will remove the focus from the grid, and the grid must have focus in order to set a cell to be editing.

Live Chat Icon For mobile
Up arrow icon