• 大小: 66KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-05-07
  • 语言: C#
  • 标签: winform  C#  

资源简介

C# winform 子窗体调用父窗体函数实现关闭该窗体打开另一个窗体;在父窗体分From1内嵌一个panel1,在panel1里载入From2,点击在子窗体From2中的按钮,清除panel1里的From2,新载入From3,点击在子窗体From3中的按钮,panel1清除,重新载入From2

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            openFoem2();
        }
        public delegate void myMethodDelegate();
        public void openFoem2()
        {
            Form2 frmS = new Form2();
            frmS.pfrm = this;
            //frmS.MdiParent = this;
            frmS.FormBorderstyle = FormBorderstyle.None;       //设置窗体为非边框样式
            frmS.Dock = System.Windows.Forms.Dockstyle.Fill;   //设置样式是否填充整个PANEL   
            frmS.TopLevel = false;
            panel1.Controls.Clear();
            panel1.Controls.Add(frmS);           
            frmS.Show();
        }

        public void openFoem3()
        {
            Form3 frmS = new Form3();
            frmS.pfrm = this;
            //frmS.MdiParent = this;
            frmS.FormBorderstyle = FormBorderstyle.None;       //设置窗体为非边框样式
            frmS.Dock = System.Windows.Forms.Dockstyle.Fill;   //设置样式是否填充整个PANEL   
            frmS.TopLevel = false;
            panel1.Controls.Clear();
            panel1.Controls.Add(frmS);
            frmS.Show();
        }

    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-05-14 10:27  子窗体操作父窗体函数\WindowsFormsApplication1\
     文件        1041  2018-05-14 10:27  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1.sln
     文件       43008  2018-05-14 15:40  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1.v12.suo
     目录           0  2018-05-14 15:35  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\
     文件         187  2018-05-14 10:27  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\App.config
     目录           0  2018-05-14 10:27  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\bin\
     目录           0  2018-05-14 10:35  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\
     文件       10752  2018-05-14 15:35  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
     文件         187  2018-05-14 10:27  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config
     文件       34304  2018-05-14 15:35  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
     文件       23168  2018-05-14 15:40  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe
     文件         187  2018-05-14 10:27  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.config
     文件         490  2017-09-29 21:43  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest
     文件        1506  2018-05-14 15:33  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs
     文件        2549  2018-05-14 10:44  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs
     文件        5817  2018-05-14 10:44  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\Form1.resx
     文件         559  2018-05-14 15:35  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\Form2.cs
     文件        2616  2018-05-14 10:39  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\Form2.Designer.cs
     文件        5817  2018-05-14 10:39  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\Form2.resx
     文件         550  2018-05-14 15:33  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\Form3.cs
     文件        2615  2018-05-14 11:14  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\Form3.Designer.cs
     文件        5817  2018-05-14 11:14  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\Form3.resx
     目录           0  2018-05-14 10:27  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\obj\
     目录           0  2018-05-14 15:35  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\
     文件        1453  2018-05-14 10:38  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7128  2018-05-14 10:30  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件           0  2018-05-14 10:27  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2018-05-14 10:27  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2018-05-14 10:27  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     目录           0  2018-05-14 10:27  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TempPE\
     文件        1460  2018-05-14 15:40  子窗体操作父窗体函数\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt
............此处省略16个文件信息

评论

共有 条评论