.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Tabbed Web browser using C#.net

Posted By:laptop charles       Posted Date: September 12, 2010    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  

Tapped Web browser using c#.net,it has used tool strip menu and five tool strip button and one toll strip textbox. it used tab control using multiple web pages. the buttons are Search,Back,Forward,home,refersh.
 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace cwebbrowser
{
    public partial class Form1 : Form
    {
        int i = 1;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            WebBrowser cha = new WebBrowser();
            tabControl1.TabPages.Add("Char pages" + i);
            tabControl1.SelectTab(i - 1);
            cha.Name = "charles";
            cha.Dock = DockStyle.Fill;
            tabControl1.SelectedTab.Controls.Add(cha);
            i++;
        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            WebBrowser cha = new WebBrowser();
            tabControl1.TabPages.Add("Char pages" + i);
            tabControl1.SelectTab(i - 1);
            cha.Name = "charles";
            cha.Dock = DockStyle.Fill;
            tabControl1.SelectedTab.Controls.Add(cha);
            i++;
        }

        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            if (i <= 2)
            {
                MessageBox.Show("do not delete");
            }
            else
            {

                tabControl1.TabPages.RemoveAt(tabControl1.SelectedIndex);
                tabControl1.SelectTab(tabControl1.TabPages.Count - 1);

                i--;
            }
            MessageBox.Show(""+i);
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            ((WebBrowser)tabControl1.SelectedTab.Controls[0]).Navigate(toolStripTextBox1.Text);
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            ((WebBrowser)tabControl1.SelectedTab.Controls[0]).GoBack();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            ((WebBrowser)tabControl1.SelectedTab.Controls[0]).GoForward();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            ((WebBrowser)tabControl1.SelectedTab.Controls[0]).GoHome();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            ((WebBrowser)tabControl1.SelectedTab.Controls[0]).Refresh();
        }
    }
}

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend