Mega Code Archive

 
Categories / C# Tutorial / GUI Windows Forms
 

Browser with Url entry box

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Net; public class BrowserWithUrlEntryBox {     [STAThread]     static void Main()     {         Application.EnableVisualStyles();         Application.Run(new Form1());     } } public partial class Form1 : Form {     public Form1()     {         InitializeComponent();     }     private void goButton_Click(object sender, EventArgs e)     {         ftpBrowser.Navigate(addressBox.Text);     } } partial class Form1 {     /// <summary>     /// Required designer variable.     /// </summary>     private System.ComponentModel.IContainer components = null;     /// <summary>     /// Clean up any resources being used.     /// </summary>     /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>     protected override void Dispose(bool disposing)     {         if (disposing && (components != null))         {             components.Dispose();         }         base.Dispose(disposing);     }     #region Windows Form Designer generated code     /// <summary>     /// Required method for Designer support - do not modify     /// the contents of this method with the code editor.     /// </summary>     private void InitializeComponent()     {         this.ftpBrowser = new System.Windows.Forms.WebBrowser();         this.label1 = new System.Windows.Forms.Label();         this.addressBox = new System.Windows.Forms.TextBox();         this.goButton = new System.Windows.Forms.Button();         this.SuspendLayout();         //          // ftpBrowser         //          this.ftpBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)                     | System.Windows.Forms.AnchorStyles.Left)                     | System.Windows.Forms.AnchorStyles.Right)));         this.ftpBrowser.Location = new System.Drawing.Point(16, 42);         this.ftpBrowser.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);         this.ftpBrowser.Name = "ftpBrowser";         this.ftpBrowser.Size = new System.Drawing.Size(917, 524);         this.ftpBrowser.TabIndex = 4;         //          // label1         //          this.label1.AutoSize = true;         this.label1.Location = new System.Drawing.Point(15, 11);         this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);         this.label1.Name = "label1";         this.label1.Size = new System.Drawing.Size(60, 17);         this.label1.TabIndex = 1;         this.label1.Text = "Address";         //          // addressBox         //          this.addressBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)                     | System.Windows.Forms.AnchorStyles.Right)));         this.addressBox.Location = new System.Drawing.Point(77, 7);         this.addressBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);         this.addressBox.Name = "addressBox";         this.addressBox.Size = new System.Drawing.Size(572, 22);         this.addressBox.TabIndex = 2;         //          // goButton         //          this.goButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));         this.goButton.Location = new System.Drawing.Point(659, 5);         this.goButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);         this.goButton.Name = "goButton";         this.goButton.Size = new System.Drawing.Size(100, 28);         this.goButton.TabIndex = 3;         this.goButton.Text = "Go";         this.goButton.Click += new System.EventHandler(this.goButton_Click);         //          // Form1         //          this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);         this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;         this.ClientSize = new System.Drawing.Size(949, 581);         this.Controls.Add(this.goButton);         this.Controls.Add(this.addressBox);         this.Controls.Add(this.label1);         this.Controls.Add(this.ftpBrowser);         this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);         this.Name = "Form1";         this.Text = "Form1";         this.ResumeLayout(false);         this.PerformLayout();     }     #endregion     private System.Windows.Forms.WebBrowser ftpBrowser;     private System.Windows.Forms.Label label1;     private System.Windows.Forms.TextBox addressBox;     private System.Windows.Forms.Button goButton; }