现有一mdi窗体,一个子窗体,更改了子窗体的图标,但是在mdi窗体里打开子窗体时,显示的还是默认的图标,最大化和最小化子窗体时,才显示更改过的图标,这是怎么回事,有人遇到过吗
mdi打开子窗体的代码:
 form1 fr = new form1 (); 
                fr.MdiParent = this;
                fr.WindowState = FormWindowState.Maximized;
                fr.Show();

解决方案 »

  1.   

    不要这2句估计就可以了
    fr.MdiParent = this; 
    fr.WindowState = FormWindowState.Maximized; 
      

  2.   

    遇到过,感觉像Bug~~忍忍吧,不伤大雅~
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication53
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();            this.Icon = new Icon(@"c:\1.ico");
                this.IsMdiContainer = true;
                Form F = new Form();
                F.Icon = this.Icon;
                F.MdiParent = this;
                F.Show();
            }
        }很正常,子窗口icon变成和主窗口一样
      

  4.   

    form1 fr = new form1 (); 
    fr.MdiParent = this; fr.Show();fr.WindowState = FormWindowState.Maximized; //改下顺序
      

  5.   

         private void newToolStripMenuItem_Click(object sender, EventArgs e)         {             MdiChildWnd child = new MdiChildWnd();             child.MdiParent = this;             child.WindowState = FormWindowState.Maximized;             child.Activated += new EventHandler(child_Activated);//注意:child_Activated是在子窗体第一次被激活时触发的事件。不过,也可以用GotFocus事件,GotFucus事件是在获点焦点时触发。             child.Show();         }        void child_Activated(object sender, EventArgs e)         {             ((Form)sender).Icon = Properties.Resources.App;         }