This is a migrated thread and some comments may be shown as answers.

Pass on Control+Z in cell

1 Answer 28 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 10 Oct 2012, 04:43 PM
I implemented undo in my application, but when a cell is selected, pressing control+z starts editing the cell. Does someone know what is the best way to prevent this from happening?

Also, when in cell edit mode, control+z is not passed along, but performs undo within the textbox. Does anyone know the best way to pass on the control+z keypresses?

1 Answer, 1 is accepted

Sort by
0
Erik
Top achievements
Rank 1
answered on 13 Oct 2012, 07:31 AM
I tried using a CellTemplate and CellEditTemplate:

<telerik:GridViewDataColumn DataMemberBinding="{Binding Title}">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Title}"
                       PreviewKeyDown="TextBoxPreviewKeyDown" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
    <telerik:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <TextBox Text="{Binding Title}"
                     PreviewKeyDown="TextBoxPreviewKeyDown" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>

But:
  • The PreviewKeyDown on the TextBlock in the CellTemplate is never triggered
  • The PreviewKeyDown on the TextBox in the CellEditTemplate is only triggered on the second key press (first key press brings the Cell in edit mode, and replaces the text with the pressed key)

Attaching a KeyDown handler to the GridViewDataColumn itself also doesn't work (KeyDown is never triggered). Does someone know how to approach this?

Tags
GridView
Asked by
Erik
Top achievements
Rank 1
Answers by
Erik
Top achievements
Rank 1
Share this question
or