简体   繁体   English

当我按Enter键时,如何在下一个单元格中进入编辑模式,而不是只关注下一个单元格?

[英]How to enter edit mode in next cell when I hit “Enter”, instead of just focus on the next cell?

Here is my code: 这是我的代码:

       <DataGridTemplateColumn  Header="xxx" Width="*" >
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBox IsReadOnly="{Binding VialPosition,Converter={StaticResource EditableCondition}}"        
                                 Background="{Binding ExtractionIDBackgroundColor, Converter={StaticResource ColorConvert}}" 
                                 TextAlignment="Center" Height="30" Width="375" 
                                 Text="{Binding ExtractionId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

How to enter edit mode in next cell when I hit "Enter", instead of just focus on the next cell? 当我按下“ Enter”键时,如何在下一个单元格中进入编辑模式,而不是仅仅关注下一个单元格?

To do such thing you are going to need some modifications on your CellStyle and also manipulate events as BeginEdit(); 为此,您将需要对CellStyle进行一些修改,并以BeginEdit()操作事件。

Here are some good examples on how to do that, i`ve used them and they worked pretty well. 这里有一些很好的例子,我已经使用了它们,并且效果很好。

These examples have all the code you need. 这些示例包含您需要的所有代码。 You`ll just need some modifications to fit your software. 您只需要进行一些修改即可适合您的软件。

Hope it helps 希望能帮助到你

Use the method BeginEdit() . 使用方法BeginEdit() The Link for this information is HERE . 此信息的链接在这里

Something like this would work: 这样的事情会起作用:

private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        e.Handled = true;
        DataGridViewCell cell = dataGridView1.Rows[0].Cells[0];
        dataGridView1.CurrentCell = cell;
        dataGridView1.BeginEdit(true);               
    }
}

You might find some use on the WPF tips and tricks editing also 您可能还会在WPF技巧和窍门编辑中找到一些用处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WPF Datagrid移动到下一行时如何进入单元格编辑模式 - WPF Datagrid How to enter edit mode of cell when moving to the next row 如何在Enter键按下事件的数据视图中将焦点移动到下一个单元格 - How to move focus on next cell in a datagridview on Enter key press event DataGridView-当我按下回车键时,它会转到下一个单元格 - DataGridView-when I press enter it goes to the next cell 将焦点移动到输入键上的下一个单元格按WPF DataGrid? - Move Focus to Next Cell on Enter Key Press in WPF DataGrid? WPF:在ItemsControl中按Enter时从一个单元格移动到下一个单元格 - WPF: Moving from one cell to the next when pressing Enter in an ItemsControl Datagridview Enter键从下一行选择下一个单元格 - Datagridview enter key selects next cell from next row 使用MVVM设计模式将焦点移到WPF DataGrid中Enter键上的下一个单元格上吗? - Move Focus to Next Cell on Enter Key Press in WPF DataGrid using MVVM design pattern? 按下Enter键时,根据其他单元格更新Datagrid单元格 - Update Datagrid cell according to other cells when hit Enter 移至Datagridview Winforms c#中Enter键上的下一个单元格 - Move to next cell on Enter key in Datagridview Winforms c# 错误发生后如何编辑DataGrid中的下一个单元格? - How I can edit next cell in DataGrid after the error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM