在WPF中编辑DataGrid的选定行 [英] edit a selected row of DataGrid in WPF

查看:522
本文介绍了在WPF中编辑DataGrid的选定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在WPF中编辑所选的dataGrid行。



我的窗口上有一个NewEntry按钮。当用户单击NewEntry按钮时,将打开一个带有表单的新窗口。当我单击保存按钮时填写此表单后,所有信息都显示在datagrid中。我已使用WPF完成此操作。现在我需要编辑特定的行。我的窗口上有一个修改按钮。我希望,用户通过单击鼠标选择一行,然后他可以通过单击修改按钮编辑此行。我怎么能这样做请给我一个建议。给我一些示例代码。



我已经在Web应用程序中执行了此操作。但我不知道桌面的语法。



这些是我的Web应用程序示例代码。请尽可能采用类似的方式

How can I edit a selected row of dataGrid in WPF.

I have a NewEntry button on my window. When user click on NewEntry button, a new window is open with a form.After filling this form when I click the save button all information are shown in datagrid.I have done it using WPF. Now I need to edit specific row. there is a modify button on my window. I wish that,user select a row by click his mouse, then he can edit this row by click modify button. How can I shall do it. please give me a suggestion. Give me some example code.

I already do it in a web application. But I don''t know syntax for desktop.

these are my sample code of web application. Please Give a similar way if possible

protected void Edit(object sender, EventArgs e)
        {
            try
            {
                _shiftManager = new ShiftManager();
                _shift = new Shift();

                int index = (((GridViewRow)(((LinkButton)(sender)).Parent.BindingContainer))).RowIndex;
                var shiftId = ((Label)gvShift.Rows[index].Cells[0].FindControl("lblCode")).Text;
                _shift = _shiftManager.GetShift(shiftId);
                FillShiftInformation(_shift);
                ViewState["_isNew"] = false;

                txtShiftCode.Enabled = false;

            }

推荐答案

有一篇关于其中 [ ^ ]


这篇关于在WPF中编辑DataGrid的选定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆