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 demo8 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void 新建NToolStripMenuItem_Click(object sender, EventArgs e) { Form2 fm2 = new Form2(); fm2.MdiParent = this; //一定记得把this所在的窗体IsMdiContainer设置为true //a.MdiParent=this 当前窗体是窗体a的父窗体;a.MdiParent=this.MdiParent 窗体a和当前窗体的父窗体是同一个窗体 fm2.Show(); } private void 垂直平铺VToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.TileVertical);//垂直平铺 } private void 层叠ToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.Cascade);//层叠 } private void hToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.TileHorizontal);//水平平铺 } private void lToolStripMenuItem_Click(object sender, EventArgs e) { foreach (Form childForm in MdiChildren) { childForm.Close(); } //关闭子窗体 } } }
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 demo8 { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) //打开网页 { try { string str = textBox1.Text.Trim(); webBrowser1.Navigate(new Uri("http://" + str)); this.Text = str; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } private void button2_Click(object sender, EventArgs e) //刷新 { webBrowser1.Refresh(); } private void button3_Click(object sender, EventArgs e) //上一页 { webBrowser1.GoBack(); } private void button4_Click(object sender, EventArgs e)//下一页 { webBrowser1.GoForward(); } } }
时间: 2024-10-13 18:17:12