本文介绍了WPF Datagrid专注于新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有datagrid,带有addnew按钮和删除按钮列。

当我点击添加新按钮时,焦点应该出现在新行上。

我该怎么办?





现在我添加了两个活动

I have datagrid with addnew button and delete button columns.
when i click on add new button the focus should come on the new row.
What should i do?


Now i have added two events

private void DataGrid_CurrentCellChanged(object sender, EventArgs e)
        {
            DataGrid.BeginEdit();
        }

private void DataGrid_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
        {
                UIElement inputElement;
                inputElement = DataGridHelper.GetVisualChild<TextBox>(e.EditingElement);
                if (inputElement != null)
                {
                    Keyboard.Focus(inputElement);
                }
        }









但是现在我必须点击两次AddNewButton来获取新行或删除我点击两次删除按钮。



解决这个问题我该怎么办? br />
请帮帮我!





But Now i have to click twice the AddNewButton for a new row to come or for deleting i have click twice the delete button.

To Solve this what should i do?
Please help me!

推荐答案


这篇关于WPF Datagrid专注于新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:32
查看更多