KB Article A330
Visible to All Users

How to Disable the Immediate Opening of In-Place Editors

Description:
How to Disable the Immediate Opening of In-Place Editors

Answer:
By default, the XtraGrid (and the XtraTreeList) opens the in-place editor immediately when clicked. For easier data browsing a user may prefer a behavior whereby a cell is not opened for editing at the first click. In other words, the first click should focus the clicked cell and then the second click on the same cell should open the editor.
It is easy to implement in the XtraGrid using the ShowingEditor event. You should store the current (focused) column and row in private fields and allow editing only if the editor is opened for a cell, which was already clicked (focused) previously.

C#
DevExpress.XtraGrid.Columns.GridColumn prevColumn = null; int prevRow = -1; private void gridView1_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e) { DevExpress.XtraGrid.Views.Grid.GridView view; view = sender as DevExpress.XtraGrid.Views.Grid.GridView; if (prevColumn != view.FocusedColumn || prevRow != view.FocusedRowHandle) e.Cancel = true; prevColumn = view.FocusedColumn; prevRow = view.FocusedRowHandle; }
Visual Basic
Imports DevExpress.XtraGrid Private prevColumn As Columns.GridColumn = Nothing Private prevRow As Integer = -1 Private Sub GridView1_ShowingEditor(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles GridView1.ShowingEditor Dim View As Views.Grid.GridView View = CType(sender, Views.Grid.GridView) If Not ((prevColumn Is View.FocusedColumn) And (prevRow = View.FocusedRowHandle)) Then e.Cancel = True End If prevColumn = View.FocusedColumn prevRow = View.FocusedRowHandle End Sub

P.S. The described approach suits the XtraTreeList. The code should be slightly changed: the focused node must be stored instead of the grid row handle.
See Also:
How to make the grid activate its in-place editor on double click only

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.