Controls. Adding Controls to Form -You can pick controls from the toolbox. -To add the controls from Toolbox to the Form You have be in design view. -To.

Slides:



Advertisements
Similar presentations
 2007 Dr. Natheer Khasawneh. Chapter 13. Graphical User Interface Concepts: Part 1.
Advertisements

CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
Chapter 2 –Visual Basic, Controls, and Events
Graphical User Interface (GUI) A GUI allows user to interact with a program visually. GUIs are built from GUI components. A GUI component is an object.
Using Multiple Forms. Creating a New Form ProjectAdd Windows Form.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
C# Programming: From Problem Analysis to Program Design1 Introduction to Windows Programming C# Programming: From Problem Analysis to Program Design 3.
Fundamentals of Programming in Visual Basic 3.1 Visual basic Objects Visual Basic programs display a Windows style screen (called a form) with boxes into.
Chapter 2 –Visual Basic, Controls, and Events
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
Controls General Discussion. VB Controls Visual Basic Controls A control is the generic name for any object placed on a form Controls may be images,
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
05/09/ Introducing Visual Basic Sequence Programming.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 1B Introduction (Tutorial)
Chapter 3 Introducing Visual Basic.NET. 3.1 Visual Basic.NET Windows Programming -Used to create Windows, Web, and Console applications -Uses predefined.
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Menus,MonthCalender, DateTimePicker, MDI,Tree View, List View,
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Assignment #1 Advanced Computer Programming.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
Introduction to the Visual Studio.NET IDE (LAB 1 )
Introduction to Visual Basic.NET Your First Visual Basic.NET Application.
Visual Basic.NET Windows Forms Hello World Homework Assignment.
BIL528 – Bilgisayar Programlama II Introduction 1.
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
New Project in Visual Basic Please use speaker notes for additional information!
Decisions and Debugging Part06dbg --- if/else, switch, validating data, and enhanced MessageBoxes.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
CSC 157 (Blum)1 Hello World. CSC 157 (Blum)2 Start/Programs/Microsoft Visual Studio.NET 2003/Microsoft Visual Studio.NET 2003.
CSC115 Introduction to Computer Programming Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA 19383
1 Advanced Computer Programming Lab Calculator Project.
Chapter 3 - VB.NET by Schneider1 Chapter 3 – Fundamentals of Programming in VB.NET Part I VB.NET Controls VB.NET Events.
1 Visual Basic Part I - A tool for customizing your program Principles of GIS
Forms and Controls Part 3 dbg --- Naming conventions, Button, Event handlers, Label.
Controls Part 2. DateTimePicker Control Used for representing Date/Time information and take it as input from user. Date information is automatically.
This is how you invoke the Microsoft Visual Studio 2010 Software. All Programs >> Microsoft Visual Studio 2010.
Simple Clicker App WPF App using C#. App Requirement Need a ‘counter’ display, which starts at 0 Need a ‘clicker’ button ! Pressing the clicker every.
Forms and Controls Part 3 dbg --- Naming conventions, Button, Event handlers, Label.
2c – Textboxes and Buttons Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Lecture Set 7 Procedures and Event Handlers Part B - The Structure of an Application Event Handlers.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Chapter 2 - VB 2008 by Schneider1 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual.
Visual Studio 2010 Hello World CSC 230.
Chapter 8: Writing Graphical User Interfaces
GUI Programming using Windows Form
3.01 Apply Controls Associated With Visual Studio Form
3.01 Apply Controls Associated With Visual Studio Form
Using Multiple Forms.
Visual programming Chapter 3: GUI (Graphical User Interface) Part I
Visual Studio 2010 Hello World CSC 230.
Simple Windows Applications
Visual programming Chapter 2: Events and Event Handling
Understanding Buttons and TextBoxes
Presentation transcript:

Controls

Adding Controls to Form -You can pick controls from the toolbox. -To add the controls from Toolbox to the Form You have be in design view. -To add the controls to the Form, simply drag and drop controls.

Adding Button Control to Form Drag and Drop

Adding Button Control to Form To open properties of the button; right click on the button and choose properties.

Fundamental Properties of the Button BackColor Cursor FlatStyle Font ForeColor Image ImageAlign Text TextAlign Enabled Visible Name Anchor Location Size

Writing Code for Button Every control has default event. Default event for Button control is Click. We have to write the code in to the handler funtion which will be executed when button is pressed. To create handler function, simply double click to the button while you are in the designer view.

Writing Code for Button Designer View Double Click Generated code

Writing Code for Button private void btnHello_Click(object sender, System.EventArgs e) ????? !!!! “btnHello_Click” function is generated by using both controls name and events name. We should write the codes in the that function which are meant to be executed when button clicked. Event handler function takes parameters which includes useful information about the fired event. These parameters are set by the system during the running the runtime. Handler function is executed when user clicks the button at the runtime.

More Events Events are the way of notifying fro a control when something of interest happened. Some events are exclusive to a control, some can be found in almost every control. Press events button on the Properties window to access and manage events that are assigned to a control in a Form.

More Events To create a handler function to an event of the control, just double click to the empty area at the right of the event.

Fundamental Events of the Form Click DoubleClick Closed Closing Focus Events Mouse Events

Fundamental Events of the Button Click Focus Events Mouse Events

Writing code for Button Control (Continues) Lets make program to give a message when Button is pressed. To achieve this first examine MessageBox class.

MessageBox MessageBox class is used for giving information to the user during execution of the program. A message could be information, error, warning or question. To display MessageBox, we should call Show method.

MessageBox Parameters 1. The control which MessageBox belongs to 2. Message body 3. Header 4. Button options 5. Icon options

MessageBox

Exercise Try different combinations of MessageBoxButtons and MessageBoxIcon enumerations.

Exercise When user tries to exit the program, usually programs ask to the user that whether he is sure. Write a program that asks to the user “Are you sure?” when form is closing. Hint: Try to use MessageBox control in the event which is fired during Form is closing.

TextBox -Used for to show information, and take input from user. - Data is stored in the Text property of the control.

Fundamental Properties of the TextBox BackColor Font ForeColor Text TextAlign MaxLength MultiLine PasswordChar ReadOnly Visible Name Anchor Dock Location Size

Fundamental Events of the TextBox DoubleClick Key Events Mouse Events

Adding TextBox Control to the Form As in the Button control, simply drag&drop TextBox control from toolbox to the Form Note: You may change location and size of the controls you have added in the designer view.

Adding TextBox Control to the Form Drag&Drop

Adding TextBox Control to the Form Set the name property of the text control to the “txtAd”.

Adding TextBox Control to the Form - Change the click event handler function of the Button as below - Run the program and enter your name the TextBox. - And than click hello button.

Label Control Looks like TextBox control Used for making explanations about other controls and giving information to the user. User can not enter input to Label control. It is read-only for the user.

Fundamental Properties of the Label BackColor Font ForeColor Text TextAlign Location Size

Exercise Write a program that asks user for his/her name and surname. Than program will write these values to the message box when user clicks the button. If name or surname entry is missing, program should warn the user.