I'd like to be able to specify a home page on the Webbrowser.
If you set the URL to be the home page in TextBox and press Enter, the home page will be displayed
Will the URL I specified come out?Please tell me how to do something like this
Both Forms and WPF should be using the WebBrowser.Navigate(string)
.The following is an example of the Forms code:
public partial class Form 1:Form
{
public Form 1()
{
// Place control.Typically InitializeComponent(); is acceptable
var button1 = new Button();
button1.Dock=DockStyle.Top;
button1.Text="Go";
Controls.Add (button1);
vartextBox1 = new TextBox();
textBox1.Dock=DockStyle.Top;
textBox1.Text="http://ja.stackoverflow.com/";
Controls.Add (textBox1);
var webBrowser=new WebBrowser();
webBrowser.Dock=DockStyle.Fill;
Controls.Add (webBrowser);
// Event handler registration (if the confirm button is used)
AcceptButton=button1;
button1.Click+=(s,e)=>
{
// URL move
webBrowser.Navigate(textBox1.Text);
};
// Event handler registration (direct return key handle)
textBox1.KeyDown+=(s,e)=>
{
if(!e.Handled&e.KeyCode==Keys.Return)
{
// URL move
webBrowser.Navigate(textBox1.Text);
e.Handled = true;
}
};
}
}
There are two parts of the code that use lambda expression (~+=(s,e)=>
~), but this is a normal event handler.Locate and register the event in the Properties window.
621 GDB gets version error when attempting to debug with the Presense SDK (IDE)
926 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
633 Uncaught (inpromise) Error on Electron: An object could not be cloned
577 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.