Prerequisites:: Microsoft Visual Studio 2008
Intended for:: Beginners
Create a New C# Windows Forms Application Project
Set New C# Project, select Windows Forms Application and name your application as MyBrowser then click Ok
You will see a default Form in FormDesigner pane
You will See This Form ready to put controls on it
Change its Text Property as MyBrowser
Change its Size to 640x480
From the toolbox place a flow layout panel onto the Form
You will notice a square as under, Dock it to Parent using the small arrow on its top right corner
Next Place a Textbox onto the flowpanel from the toolbox, resizing to almost 75% of the form
Next Place a button also from the toolbox, change its text property to 'Go'
Then place a WebBrowser control, and resize it accordingly dragging its bottom right corner to your forms extreme bottom right corner
Your form design is ready, it will look as under:-
Press F5 to see it work, You can Make it look as Cute as possible
Now its time to write some functionality i.e we would like to pick the text from the textbox when the user clicks the go button the browser control should load the desired page
To program this action, Double Click the Go Button
And place the following code in the function 'button1_Click(bla bla)'
////////////////////////////////////////////////
String w = textBox1.Text;
webBrowser1.Url = new System.Uri("http://"+w);
webBrowser1.Refresh();
//////////////////////////////////////////////
Press F5, Your minimalistic browser is now Functional
e.g Type in a website name (for now don't type http://)
make sure you are already connected to the internet and hit go
There You are, Have Fun, You can improve it to your liking
Do you find this tutorial Useful, Please Have your say in comments.
No comments:
Post a Comment