我有  三个窗口  A 窗口  B窗口  C窗口A窗口用showdiadog 弹出 B窗口后      在B窗口有两个按钮   这两个按钮都是弹出C窗口选择文件用    第一个按钮用showdiadog弹出C窗口  选择文件后关闭时连B窗口一起关闭了        这是怎么回事啊???
但第2个按钮弹出C窗口 选择文件后  B窗口就不关闭了                谁能告诉我啊  

解决方案 »

  1.   

    C窗口关闭都是this.close()
    弹出也是c.showdiadog()
      

  2.   

    你是不是在B窗口中写了:this.Close();
      

  3.   

    b窗口只有 关闭按钮才写了 this.close()
    c窗口的
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace EnNo.Manger.Utils
    {
        public partial class ChooseTemplets : Form
        {
            private TextBox textboxto;
            private string filepath = "";
            private string classAction;        public string ClassAction
            {
                get { return classAction; }
                set { classAction = value; }
            }        public ChooseTemplets(string ca, TextBox text)
            {
                this.textboxto = text;
                ClassAction = ca;
                InitializeComponent();
            }        private void ChooseTemplets_Load(object sender, EventArgs e)
            {
                switch (ClassAction)
                {
                    case "MerChant":
                        filepath = "\\Templets\\MerChant";
                        break;
                    default:
                        break;
                }            LoadList();
            }        #region 加载
            void LoadList()
            {
                listView1.View = View.Details;
                listView1.SmallImageList = imageList1;            ColumnHeader header;
                header = new ColumnHeader();            header.Text = "文件名称";
                header.TextAlign = HorizontalAlignment.Left;
                header.Width = 330;            listView1.Columns.Add(header);            System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(Environment.CurrentDirectory + filepath);            System.IO.FileInfo[] files = dirInfo.GetFiles("*.*");            if (files != null)
                {
                    foreach (System.IO.FileInfo file in files)
                    {
                        ListViewItem item = new ListViewItem(file.Name);                    item.SubItems.Add(file.CreationTime.ToString());
                        item.SubItems.Add(file.Extension);                    switch (file.Extension)
                        {
                            case ".html":
                                item.ImageIndex = 0;                            break;
                            case ".htm":
                                item.ImageIndex = 1;                            break;
                            case ".shtml":
                                item.ImageIndex = 2;
                                break;
                            default:
                                break;
                        }                    listView1.Items.Add(item);
                    }
                }
            }
            #endregion        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
            {
                string key = null;
                if (listView1.FocusedItem != null)
                    key = listView1.FocusedItem.Text;            textBox1.Text = "/{@Templets}/" + ClassAction + "/" + key;
            }        private void button1_Click(object sender, EventArgs e)
            {
                this.Close();
            }        private void button2_Click(object sender, EventArgs e)
            {
                this.textboxto.Text = textBox1.Text;
                this.Close();
            }
        }
    }
      

  4.   

    但我值用 show()弹出B窗口就一切正常
      

  5.   

    应该在B中写个函数关闭
    在C中调用关闭函数在关闭C。
      

  6.   

    给你一个参考:
    http://blog.csdn.net/gisfarmer/archive/2008/08/04/2767338.aspx