using Microsoft.Web.WebView2.WinForms;
using System;
using System.Windows.Forms;
namespace WebView2Example
{
public partial class MainForm : Form
{
private WebView2 webView;
public MainForm()
{
InitializeComponent();
InitializeWebView();
}
private async void InitializeWebView()
{
webView = new WebView2();
webView.Dock = DockStyle.Fill;
this.Controls.Add(webView);
// Initialize the WebView2 environment and specify the folder where user data will be stored.
await webView.EnsureCoreWebView2Async(null);
// Navigate to a URL
webView.CoreWebView2.Navigate("https://www.example.com");
}
}
}
Microsoft.Web.WebView2.WinForms
和 System.Windows.Forms
命名空间,这是为了使用 WebView2 控件和 Windows Forms 应用程序。Form
的类,表示应用程序的主窗口。如果你需要更详细的解释或有其他问题,请随时告诉我!
上一篇:c# override
下一篇:c#获取时间戳
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站