KB Article A281
Visible to All Users

How to make my grid columns read-only

Description:
I have an XtraGrid with several columns and want to prevent some of the columns from being edited. What is the best way of doing this?

Answer:
There are several possible solutions.

  • The first solution is to set the GridView.OptionsBehavior.Editable property to False. In this case, the whole grid becomes read-only.

  • Another solution is to change the ReadOnly or AllowEdit option of your columns.

  • Starting with version 19.2 Grid Control supports Disabled Cell Behavior that allows you to disable individual grid cells with ease.

  • The last solution is to use the ShowingEditor event of the view and disable cell editing via code using the event handler's e.Cancel parameter. You can learn more about this approach in the How to Conditionally Prevent Editing for Individual Grid Cells article.
    Note The column's ReadOnly option when activated still allows you to open the in-place editor, but disables editing, you can only select and copy the content of the entered cell or drop the editor's dropdown section for review (this might be useful in case of read only image or memo dropdowns), the other solutions will completely disable any access.

Comments (2)

    I don't see the Editable option of the GridView.OptionsBehavior property on my grid. Is this for Webforms or WinForms?

    How can I achieve this functionality for Webforms?

    Thanks in advance

    Nadezhda (DevExpress Support) 8 years ago

      Hello,

      I've created a separate ticket on your behalf (How to disable editing). It has been placed in our processing queue and will be answered shortly.

      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.