使用来自详细信息表单的新数据更新主表单gridview [英] updating master form gridview with fresh data coming from detail form

查看:55
本文介绍了使用来自详细信息表单的新数据更新主表单gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个简单的问题。我想要做的是刷新我的主表单上的网格并绑定到数据集。用户双击网格上的一行,弹出一个详细信息表单,他更新记录将其保存在数据库中,然后返回到主表单。我将来自详细信息表单的新数据集与主服务器中的一个合并。但没有任何反应。网格显示旧数据(数据已成功保存在数据库中)。这里的代码是:



this is a simple question. what i am trying to do is refresh my grid that is on my master form and bound to a dataset. the user double clicks a row on the grid a detail form pops up he updates the record saves it in the database and then returns to the master form. where i merge the fresh dataset coming from the detail form with the one of the master. but nothing happens. the grid shows the old data(the data are successfully save in the db).here''s the code:

private void employeesDataGridView_DoubleClick(object sender, EventArgs e)
        {
            //get the selected row
            int row = employeesBindingSource.CurrencyManager.Position;
            NORTHWNDDataSet.EmployeesRow emprow =(NORTHWNDDataSet.EmployeesRow) nORTHWNDDataSet.Employees.Rows[row];
            
            //create the detail form and pass this form to the constructor
            //and also the selected row
            EmployeesDetails det = new EmployeesDetails(this);
            det.Data = new NORTHWNDDataSet();
            det.Data.Employees.ImportRow(emprow);
            det.ShowDialog();

            //merge the fresh data with the old ones
            nORTHWNDDataSet.Merge(UpdatedData, true, MissingSchemaAction.Ignore);
            nORTHWNDDataSet.AcceptChanges();



        }

推荐答案

你可以去代表和事件概念。这会将更新的行传递给包含datagrid的主表单,您可以将新数据与旧数据合并。
you can go for delegate and event concept. this will pass the updated row to your master form with datagrid and you can merge fresh data with old data.


这篇关于使用来自详细信息表单的新数据更新主表单gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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