[英]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 希望能帮助到你
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.