Presentation is loading. Please wait.

Presentation is loading. Please wait.

GUI Programming using Windows Form

Similar presentations


Presentation on theme: "GUI Programming using Windows Form"— Presentation transcript:

1 GUI Programming using Windows Form

2 Get started Other than creating console based application ,you can use visual studio to create Visual Basic programs with professional user interfaces

3 Form You will be brought the “Design” view with a default form
increase the form area by dragging its border

4 UI control Label Text box Button List box
Open the “Toolbox” which should be in the left hand side of visual studio This is where we will drag and drop our UI control form .

5 Labels A Label control lets you place descriptive text , where the text does not need to be changed by the user. Add a Label control to the form. Click Label in the Toolbox and drag it over the forms Designer and drop it in the desired location. If you want to change the display text of the Label, you have to set a new text to the Text property of Label. Label1.Text = "This is my first Label“ or

6 Properties You can also try to change other properties of the UI control object and see what happens . For example , font color ,font size etc. In general , properties are used to control the attributes of the UI control Press “F5” to run your application

7 Button A Button is a control, which is an interactive component that enables users to communicate with an application which we click and release to perform some actions. When you want to change display text of the Button , you can change the Text property of the button. Button1.Text = "My first Button"

8 MsgBox Function Displays a message in a dialog box Structure : MsgBox(msg, MsgBoxStyle, Title) Ex: MsgBox("Hello", MsgBoxStyle.Information, "ccsa227") The MsgBoxStyle enumeration values are listed in the following table. Member Description OKOnly Displays OK button only. OKCancel Displays OK and Cancel buttons. YesNoCancel Displays Yes, No, and Cancel buttons. YesNo Displays Yes and No buttons. RetryCancel Displays Retry and Cancel buttons. Question Displays Warning Query icon. Exclamation Displays Warning Message icon. Information Displays Information Message icon.

9 Implementing code in a form
Visual Studio has generated code for you when you drag and drop UI controls into the form

10 Generating the Click Event
You will be brought to the code editor and method ‘button1_click’ will be generated What this method does it that whenever you click on the button in your application , this method will execute . Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click End Sub End Class

11 Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click MsgBox("added " + TextBox1.Text ) End Sub End Class

12 List box A Windows Forms List Box control displays a list of choices which the user can select from. You can use the Add method to add items to a list box. The Add method adds new items at the end of an unsorted list box Ex: ListBox1.Items.Add("Sunday")

13 Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click ListBox1.Items.Add(TextBox1.Text + " " + TextBox2.Text) End Sub End Class

14 Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click ListBox1.Items.Remove(ListBox1.SelectedItem) End Sub End Class

15

16

17


Download ppt "GUI Programming using Windows Form"

Similar presentations


Ads by Google