Windows Forms Application:
It is used for developing an application for the desktops with an effective User Interface.
“Whenever a class inherits “System.Windows.Forms.Form” class then it is said to be a windows form.
To Create Windows Forms Application:
VS.Net IDE for Win form Development. To Box (Ctrl+Alt+X): It maintains all the controls that can be used within the Win form.
Properties Window (F4):
It is used to set or get value from the private or protected members of the class.
Solution Explorer (Alt+Ctrl+L):
It maintains all the files that are used within the application.
It acts like a canvas where other controls can be drawn on it.
It is used to provide any static information on the Form.
Common Properties for all Windows Form Controls:
Name: Used to specify a unique identifier for the control. Text: It is used to set or get the value from the control.
It is used to accept the single Line, Multi-Line, or password characters as the input.
If set to true then the user can provide input in multiple lines.
Scroll Bars: I
t is used to attach the scroll Bars to the control.
It is used to display the specified char on the text box instead of the value typed by the user
It is used to raise the action.
It is used to allow the user for selecting a value within a range.
Save File Dialog Control:
It is used to project the dialog Window for saving the file within the system.
Open File Dialog Control:
It is used to project the dialog window for selecting the file which is present within the system.
The above two controls are used only to project dialog windows but they will not save the file or either open the file.
Common Properties of above two Controls:
Filter: Using to specify the filter expression to be used for displaying the files within the dialog window.
Used to return the name of the file selected within the dialog window.
Common Methods for the above two Controls:
Show Dialog (): It is used to project the dialog window.
C: program filescsMicrosoft visual studio common7 VS2008 image library 1033
For Button2 For Button3
Text: Record Text: Close
Name: btn Record Name: btnClose
Text Align: Bottom Center Text Align: Bottom Center
Image: - - - Image: - - -
Image Align: Top center Image Align: Top center
In order to support speech API .Net uses System.Speech Name Space
Click on the project [menu]
Add Reference ()
.Net (Tab) ()
Select system speech
Code for Read button
Before write Namespaces
Imports System Speech.Synthesis à provides classes to convert text to voice.
Code for Read button
Dim SS as New speech Synthesizer à Provides methods to convert text to voice.
SS.Rate = tbSpeed.Value
SS.Volume = tbVolume.Value
SS.SelectVoice (“Microsoft SAM”)
Dim sfd as new SaveFileDialog
Sfd.Filter = “WaveFile*.wav
Dim ss as new speechSynthesizer
ss.Rate = tb.Speed.Value
ss.Value = tb.Volume.Value
ss.SetOutput To WaveFile (sfd.FileName)
MessageBox.Show (“Text recorded as voice”, VB270 “Text2Voice Convertor”)
Code for close
Backcolor = __[--] (select)
Text = VB270 Text2voice Convertor
Icon: Select any good icon (.ico)
Start Position: Centre Screen [For the application to appear whenever executed]
Maximize: False (user can’t maximize form)
Web Browser Control:
It is used to provide the browsing capabilities to the Windows Form.
It is used to logically group the controls together.
Designing our own Browser:
File menu new Project windows form application OK
Drag and drop group Box on the form according to our request set the properties as Dock: left, Text: options
Drag & drop another group box and set the property Dock: Top
In the remaining space on the form, we want to develop a browser.
Drag & drop web browser control on remaining space .
In 1st Groupbox (options)
Select (drag & drop) button
Text align: bottom center
Image: select an image (ß) (path is in the above program)
Image align: Top center
Put several buttons one under the other in options Groupbox
|Text: Forward||Text: Refresh||--- home|
|Text align: Bottom center||Text align: Bottom center||Text align: Bottomcenter|
|Name: btnforward||Name: btnRefresh||Name: btnhome|
|Image: __ ()||Image: --- ( )||Select on image|
|Image Align: Top center||Image Align: Top center||Image Align: Top center|
Btn read btn close
---- (--) ---- (--)
---- (--) ---- (--)
For send Group box text = Address URL
Take Textbox under the text, place a button after this text box button properties
Properties: Name: txtURL
Name: btnGo, Image = select -> __
Text: Go Image Align: Middle Text
// Code for Go button
Dim URL as String
URL = txtURL.Text
Dim protocol as string
Protocol = Mid (URL, 1, 4)
If protocol Upper = “HTTP”
txtURL.Text = “http: //” & URL
Web Browser1.URL = New URL (txtURL.Text)
Catch ex as Exception
MessageBox.Show (ex.message, Me.Text)
We may have a
user enters a valid or invalid URL so depending on this we use to try that thing and if exception occurs we catch this so we use Exception handling.
In website find b4 www http: //to use this we have protocol. We have to read URL from middle of string for this we have mid The user may enter URL in upper case lower case or both so we must try to convert into upper or lower The user may enter http or not so we need to concatenate http with URL http: //& URL Code for Back button ‘Back (button_Click) webBrowser.GoBack (); For Forward button_click Webbrowser.Goforward () For Refresh WebBrowser1.Refresh () For Home WebBrowser1.GoHome () Click on project [menu] à add reference à Under .Net tab select System.Speech (OK) Click on Read button for code Write on top of public class Form1 Imports System.Speech Imports System.SpeechSynthesis Code for Read (button_Click) Dim ss as new Speech Synthesizer Try ss.Rate = 2 ss.Volume = 100 Dim msg as string Msg = webBrowser1.Document.Body.OuterText (Text on in our site which is to be speaked out) ss.SpeakAsync (msg) Catch ex as Exception ss.SpeakAsync (ex.Message) MessageBox.Show (ex.Message, Me.Text) End try Code for close button End Execute and check For form properties Text: vb270 WebBrowser with voice support Icon: select a browser symbol WindowState: Maximized. Creating a basic setup project (if you want to give your s/w for others but not code) Open soln.Explorer Above oca application we find solution Rclick on solution and select add new project We find (+) other project type Under this visual studio installer Select (1click) on this And select setup project on middle of form. Name vb270 Webbrowser with voice support Click on OK We get a form like (+) Application Folder (+) Users Desktop (+) User’s program menu Rclick on application and click add à add à project output click on others Once we click on project out click OK Again Rclick on application à add à file à (select an icon which we selected for our application) Select Users Desktop And Right click on Blank Frame | [Rclick] And click on Create New shortcut Then window will be opened Click on application folder Select “Primary output from vb270 Webbrowser Click OK Open properties of “Primary output from vb270 webbrowser” Name: vb270 Webbrowser with voice support Description: Icon: Select Icon file what we have added to our program Select Users program menu and Rclick and Add Folder Name: vb270 batch application Users program menu à vb270 batch applications Select vb270 batch application and Rclick on blank frame and select create new shortcut and follow indtructions performed at users desktop. (|userprgrmàvb270|Rclick|) After wards we find in menu bar Debug select this mode for deployment. [There will be debug and release mode. Debug shows of there are errors do you want to debug to open VS IDE but in release mode it says if errors are there errors and do you want to terminate application.] [If our project is under construction we select debug] [If our project is completed we select release] Click on Build menu & Build solution Go 2 solutions Explorer Rclick on our application (vb270 Webbrowser with support) and click on build. Save it as your wish
It is used to execute a set of instructions repeatedly for every specific interval of time. Property: Interval: Specify the duration in milliseconds to halt the timer control execution. Enabled: It is used to enable or disable the execution of the timer control.
Tick: Executes the code present within the Event handler for every elapsed time provided at the interval of timer control. Ex: Take WIN FORM application. Below the form drag & drop timer control that area is called as Component tab. Label1 Id = lbttime Button1 Id = lb1start watch, text = Start watch Button2 Id = lb1start watch, text = Stop watch Timer1 Interval = 1000 Enable = False (code written in timer would not be execute) Double click on Timer Control
Code for Timer
‘Timer1_tick Lb1Time.Text = Now ToLongTimeString
Code for start button1 (start watch)
‘Start Watch Timer1.Enabled = true
Code for stop watch (stop button)
‘Stop Watch Timer1.Enabled = false Execute Image list: It is used to maintain a collection of images which can be used by any control that has a capability to project the image. Draw some images in order to make animation Picture Box: It is used to project an image. Property: Image URL: Specify the URL of the image to be displayed. Size mode: Specify the mode of image to be displayed. Ex: Picture Box1: Mode = stretched Button 1: Id = btn start Id = btn pause btn continue btn close Text = start = pause continue close Drag & drop timer control, image list control below form For Timer1 Enabled = false Interval = 500 Click on Image List Task (|<|) Image size: 255, 255 Image list Depth: Depth 32 bit Choose Images à click on this Add and select all images created by us for animation. Timer1 code: Above Timer code in class Form2 ‘Form declarations Dim index as Integer = 0 Code in Timer: ‘Timer_tick If Index > ImageList1.Images.Count – 1 Then index = 0 pictureBox1.image = ImageList1.Images (index) Index t = 1 Code for start button ‘Start (button_Click) Timer1.Enabled = True btnStart.Enabled = False Pause btn: ‘Pause (button2_Click) Timer1.Enabled = False Continue btn: ‘Continue (button3_Click) Timer1.Enabled = True Close btn: ‘Close (button4_Click) End ADD.Net usage Open windows forms application Name: VB270SQL Client Tool
|For Label1:||For Label2: For label3:|
|Text: Enter your statement||Text: history Name: |b|result|
|For Button1:||For Button2:||For Button3:||For Button4:|
|Text: Execute||Text: Clear||Text: Clear History||Text: Close|
|Name: btn Execute||Name:||Name: btn clear history||Name: btn close|
|For Grid View|
|Name: dgv Results|
|For Text Box|
|Name: txt Stmt|