在wpf或winform关闭子窗口或对子窗口进行某个操作后刷新父窗口

父窗口:

///<summary>
///弹出窗口 
///</summary>
///<param name="sender"></param>
///<param name="e"></param>
privatevoid miFuncSet_Click(object sender, RoutedEventArgs e)
{
WinFuncSetting funcSetting =new WinFuncSetting();
funcSetting.ChangeTextEvent +=new ChangeTextHandler(FuncSettingClosed);
funcSetting.ShowDialog();
}
//设置窗口关闭时执行的方法
void FuncSettingClosed()
{

      //写你想调用的方法,如重新绑定数据源啊 改变某标签的值啊 等等

     }

子窗口:

namespace EFM.FuncTest.assist
{
//定义委托
publicdelegatevoid ChangeTextHandler();
///<summary>
/// FuncSetting.xaml 的交互逻辑
///</summary>
publicpartialclass WinFuncSetting : Window
{
publicevent ChangeTextHandler ChangeTextEvent;
public WinFuncSetting()
{
InitializeComponent();
}

//窗口关闭事件 你可以在任意你需要的操作后触发事件,我这里是写在窗口关闭里
    privatevoid Window_Closed(object sender, EventArgs e)
    {
        StrikeEvent();
    }
    //触发事件改变MainWindow的值
    privatevoid StrikeEvent()
    {
        if (ChangeTextEvent !=null)
        {
            ChangeTextEvent();
        }
    }

}

时间: 2024-08-17 11:50:50

在wpf或winform关闭子窗口或对子窗口进行某个操作后刷新父窗口的相关文章

在winform中,关闭窗口时刷新父窗口(原来打开此窗口的窗口)

如何在关闭窗口时刷新父窗口(原来打开此窗口的窗口,不一定是mdi窗口), 这种事情在b/s里很简单,但在winform里却不那么好办.因为你不能关闭第一个窗口时再打开另一个窗口,如果这样的话新窗口就一起被关闭了.但是正因为这样,我们可以让刷新的动作在关闭子窗口时进行,当然所有的动作是在父窗口中进行的.晕,不知道说明白了没有.还是看一下例子吧public partial class Customer : Form    {        public Customer()        {    

自己收藏-javascript用window.open的子窗口关闭自己并且刷新父窗口

function closeMeAndReloadParent() { opener.location.reload(); window.close(); } 一种在父窗口中得知window.open()出的子窗口关闭事件的方法 <HTML><BODY><P> </P><form name=fm_Info><input type=text name=txtValue></form><script language=j

JS实现关闭当前子窗口,刷新父窗口

一.JS实现关闭当前子窗口,刷新父窗口 JS代码如下: <script> function refreshParent() {  window.opener.location.href = window.opener.location.href;  window.close();   }              </script>

JS实现关闭当前子窗口,刷新父窗口及调用父窗口的方法

一.JS实现关闭当前子窗口,刷新父窗口 JS代码如下: <script> function refreshParent() { window.opener.location.href = window.opener.location.href; window.close(); } </script> html页面代码如下: <input type="button" id="btn1" class="btn" valu

javascript 跨域子窗口关闭并刷新父窗口

//实现javascript 跨域子窗口关闭并刷新父窗口 function winOpen(url){            var win=window.open(url,'','height=480,width=670,top=300,left=300,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no');              setInterval((function(win){retur

js关闭子窗口,刷新父窗口

父页面js:function btnAdd_onclick() {window.open("xxx.jsp", "","height=600, width=650, top=100, left=200,z-look=yes,toolbar=yes, menubar=no, scrollbars=yes, resizable=yes ,alwaysRaised=yes,location=no, status=yes" );} function re

关闭当前的子窗口,刷新父窗口,弹出层提示框

近期,在做后台的管理页面,为了有更好的用户体验,需要实现关闭当前页面,刷新父窗口,在网上查找方法,如下: JS代码如下: <script>  function refreshParent() {   window.opener.location.href = window.opener.location.href;   window.close(); } </script> html页面代码如下: <input type="button" id="

JavaScript:关闭弹出窗口时刷新父窗口

JavaScript:关闭弹出窗口时刷新父窗口 2010-08-13 09:25:29|  分类: 代码示例 |举报 |字号 订阅 说明: 关闭弹出窗口时刷新父窗口也可以说是关闭子窗口时自动刷新父窗口中的信息,即用户通过window对象的open()方法打开一个新窗口(子窗口),当用 户在该子窗口中进行了数据库操作(如数据添加.修改和删除等)之后,关闭子窗口时,系统会自动刷新父窗口来实时更新信息; 思路和技术: 主要应用window.open()语句打开新窗口,并在新窗口中应用opener属性,

javascript关闭弹出窗口时刷新父窗口和居中显示弹出窗

居中显示用到了moveTO()方法: 关闭弹出窗时刷新父窗口用到了window.opener方法: 父窗口代码如下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="弹出窗口.aspx.cs" Inherits="弹出窗口" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transiti