问题描述
我受命制作4个网络浏览器的布局,以后可用于安全摄像机。
Web浏览器部分很简单,但是我一直坚持使其具有响应能力,因为当您运行它并最大化程序时,Web浏览器的分辨率保持不变。由于该程序将在大屏幕上运行,因此必须响应分辨率。
我在Internet上四处张望,没有找到解决方案。我已经尝试过锚定,但是当我这样做并扩大程序时,浏览器会互相重叠。我试过将它们放在流网格和表网格中。我发现的其他内容是“ this.AutoSize = true;”但是我对C#表单有点陌生,对此不理解。
有人可以帮忙吗?
发生的事情的代码和几张照片
how it is now
代码:
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 webspace
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void webbrowser1_DocumentCompleted(object sender,WebbrowserDocumentCompletedEventArgs e)
{
}
private void Form1_Load(object sender,EventArgs e)
{
webbrowser1.Navigate("www.nos.nl");
webbrowser2.Navigate("www.google.com");
webbrowser3.Navigate("www.facebook.com");
webbrowser4.Navigate("www.google.com/maps");
this.AutoSize = true;
}
private void webbrowser1_Navigating(object sender,WebbrowserNavigatingEventArgs e)
{
this.Text = e.Url.ToString() + "is loading...";
}
private void webbrowser2_Navigating(object sender,WebbrowserNavigatingEventArgs e)
{
this.Text = e.Url.ToString() + "is loading...";
}
private void webbrowser3_DocumentCompleted(object sender,WebbrowserDocumentCompletedEventArgs e)
{
this.Text = e.Url.ToString() + "is loading...";
}
private void webbrowser4_DocumentCompleted(object sender,WebbrowserDocumentCompletedEventArgs e)
{
this.Text = e.Url.ToString() + "is loading...";
}
private void webbrowser2_DocumentCompleted(object sender,WebbrowserDocumentCompletedEventArgs e)
{
}
private void webbrowser3_DocumentCompleted_1(object sender,WebbrowserDocumentCompletedEventArgs e)
{
}
}
}
解决方法
在另一个Orientation=Horizontal
的SplitContainer内部具有两个Orientation=Vertical
SplitContainer s的布局(反之亦然,在水平线的任一侧有两个垂直线)
调整表单大小时,将所有SplitContainer的SplitterDistances适当地设置为宽度/高度的50%。除非用户自定义了它们(在这种情况下,决定要执行的操作,例如按比例调整大小,从而使用户可以有些观点比其他观点更大
使网络浏览器控件Dock =填充其面板
请注意,WebBrowser控件现在已经很老了,应该替换为WebView2(基于Chrome的Edge)