DevExpress GridControl cells' inner text selectable but not editable

自闭症网瘾萝莉.ら 提交于 2019-12-20 07:29:02

问题


GridControl is working like~ Excel natively:

  1. Clicking once on the cell selects it. Copy copies the cell value and the header.
  2. Clicking twice on the cell selects the inner text. Copy copies only the inner text.

I am working on preventing the cell edition hooking the ShowingEditor event, setting the edition to e.Cancel.

However this prevents the behaviour 2. above. I'd like to still be able to select the inner text for copy, just that I'd like it to be not editable.

Would you know how to do this? Fyi, this behavior can be achieved at a column level by setting the ReadOnly to true:

<dxg:GridControl.Columns>
    <dxg:GridColumn FieldName="field" ReadOnly="True"/>

EDIT

My grid is setup like this:

<dxg:GridControl>
    <dxg:GridControl.Resources>
    </dxg:GridControl.Resources>
    <dxg:GridControl.View>
        <dxg:GridControl.TableView>
        </dxg:GridControl.TableView>
    </dxg:GridControl.View>
    <dxg:GridControl.Columns>
    </dxg:GridControl.Columns>
</dxg:GridControl>

Thank you!


回答1:


Have you tried

GridView.OptionsBehavior.CopyToClipboardWithColumnHeaders = False

Also you could try this approach suggested by DevExpress

Copy single cell content to clipboard from XtraGrid when user presses Ctrl+C



来源:https://stackoverflow.com/questions/26172343/devexpress-gridcontrol-cells-inner-text-selectable-but-not-editable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!