【问题标题】:Pasting into DataGridTextColumn? (WPF)粘贴到 DataGridTextColumn? (WPF)
【发布时间】:2015-11-08 01:30:37
【问题描述】:

我有一个 DataGrid,其中一个列是 DataGridTextColumn。当用户按下回车键时,DataGrid 将它们带到下一行,用户可以在其中立即开始输入,而 DataGridTextColumn 接受输入就好了,耶!

问题是,在他们填写完一行后,按回车键转到下一个填写,他们必须键入才能激活该列。非常重要的是,用户可以在被带到新列后立即使用 CTRL+V 进行粘贴,并且粘贴的信息将自动激活文本列,而无需他们输入。

我该怎么办?

【问题讨论】:

标签: c# wpf mvvm wpfdatagrid


【解决方案1】:

想法与建议的 Dimitris Batsougiannis 相似,但改为选中 Ctrl

<DataGrid KeyDown="DataGrid_KeyDown"...

private void DataGrid_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl)
    {
        var dataGrid = (DataGrid)sender;
        if (dataGrid.CurrentCell != null)
        {
            dataGrid.BeginEdit();
        }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-15
    • 1970-01-01
    • 2011-05-06
    • 1970-01-01
    • 2013-10-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多