DevExpress GridControl cells' inner text selec

2020-05-05 17:47发布

问题:

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