110,541
社区成员
发帖
与我相关
我的任务
分享
private void Form1_Activated(object sender, EventArgs e)
{
foreach( Form frm in System.Windows.Forms.Application.OpenForms)
{
if (frm is Form2) frm.BringToFront();
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Activated+=new EventHandler(Form1_Activated);
}
Form2 frm;
private void button1_Click(object sender, EventArgs e)
{
frm= new Form2();
frm.Show(this);
}
private void Form1_Activated(object sender, EventArgs e)
{
if (frm != null)
frm.Activate();
}
}
}