Using Multiple Forms.

Slides:



Advertisements
Similar presentations
Microsoft Expression Web-Illustrated Unit J: Creating Forms.
Advertisements

CPIT 102 CPIT 102 CHAPTER 1 COLLABORATING on DOCUMENTS.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
Creating Custom Forms. 2 Design and create a custom form You can create a custom form by modifying an existing form or creating a new form. Either way,
Using Multiple Forms. Creating a New Form ProjectAdd Windows Form.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Chapter 5 Java Script And Forms JavaScript, Third Edition.
BIM211 – Visual Programming Database Operations II 1.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Using Arrays and File Handling
BİL528 – Bilgisayar Programlama II Database Operations II 1.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
Preview four Pages Click Here-----Click and Drag to Select 4 pages.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Microsoft Office 2007 Access Chapter 6 Using Macros, Switchboards, PivotTables, and PivotCharts.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Key Applications Module Lesson 21 — Access Essentials
Access Manual 2 By Dhawala Kovuri Elham S.Khorasani Ismail Guneydas.
11-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
Access Forms and Queries. Entering Data in Your Table  You can add data to your table in Datasheet view, by typing in the columns and rows.  This.
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.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Copyright © 2012 Pearson Education, Inc. Chapter 5 Loops, File, and Random Numbers.
Chapter 3 Automating Your Work. It is frustrating when you have to type the same passage of text repeatedly. For example your name and address. Word includes.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
Compunet Corporation Programming with Visual Basic.NET Working with Menus and Dialog Boxes Week 14 Tariq Aziz and Kevin Jones.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 6 1 Microsoft Office Access 2003 Tutorial 6 – Creating Custom Forms.
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 11 Data Files.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
Chapter 8 Multiple Forms, Modules, and Menus. Introduction This chapter demonstrates how to: – Add multiple forms to a project – Create a module to hold.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Dive Into® Visual Basic 2010 Express
Excel Tutorial 8 Developing an Excel Application
Chapter 5 Validating Form Data with JavaScript
About the To-Do Bar in Outlook
Using Macros, Switchboards, PivotTables, and PivotCharts
Maintaining a Database Using the Design and Update Features of Access
Chapter 1: An Introduction to Visual Basic 2015
Building a User Interface with Forms
Tabs, Line & Paragraph Spacing, and working with lists
STUDENT INFORMATION SYSTEM (SIS)
How to design a Windows Forms application
Visual programming Chapter 1: Introduction
Access Lesson 1 Understanding Access Fundamentals
File Input/Output (I/O)
Chapter 7 Advanced Form Techniques
Microsoft Office Access 2003
Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy
Multi-form applications and dialogs
NORMA Lab. 7 Generating Reports More Display Options
Microsoft Office Access 2003
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
Simple Windows Applications
HP ALM Defects Module To protect the confidential and proprietary information included in this material, it may not be disclosed or provided to any third.
Module 8: Creating Windows-based Applications
Using Templates and Library Items
How to organize and document your classes
Classes.
STUDENT INFORMATION SYSTEM (SIS)
Lecture 5 Menu Strip Demo with Dialog Controls.
Presentation transcript:

Using Multiple Forms

Creating a New Form Project Add Windows Form

Creating a New Form Select Windows Form Name of the form

You can set properties of the form as usual. Creating a New Form You can set properties of the form as usual.

Adding Controls to the Form Drag and drop controls Controls

Properties should be set Button Properties Button Properties should be set

Making “Button” Functional Events Properties Click Event Double click to create a “handler” to the “Click” event.

Generated Code

Creating and Opening new Form Creating a new form object frmNew frm = new frmNew (); Modal and Modeless Forms Modal -> frm.ShowDialog(this); Modeless -> frm.Show(); Name of the object “new” keyword Constructor Class name

Creating and Opening new Form - Code

Creating and Opening new Form - Result

Closing the Form To write the code that will close the form, first add a button to the form named “Close”. Then double click on the button and add the code below. Code

Transferring Data between forms Send data via constructor. Constructor

Example Add a new ListView to frmMain.

ListView Properties

Adding Columns to ListView

Adding Columns to ListView

Working with data Operations: Add/Delete/Modify We will need to create a new form for addition and modification operations. Deletion operation will delete selected record.

Add/Delete Data To perform deletion and modification operations, first we add two new buttons to the form and assigning appropriate properties.

Add new record To transfer data, first define a “struct” named Uye.

Add/Modify Form Create a new form named “frmKayitEkleDuzelt” to perform add and modify operations. Add three textboxes and labels, one OK and one Cancel buttons to the form.

Displaying records in add/modify form Get data in Uye structure via constructor and assign to the controls. Assign Operation

OK and Cancel Buttons How can we understand that user pressed OK or Cancel buttons? How to send data back?

Solution First, define a global Uye structure.

Solution - Continues Double click to OK and Cancel buttons, add following codes to handler functions. Structure to be returned.

Solution - Continues Create a public function on “frmKayitEkleDuzelt”form. This function will return the global struct m_Uye which is created by OK button click. Code that will return structure.

Main form- Add To add a new record, add following code to the handler function of the Ekle button Adding record form Empty Uye struct If OK button is pressed Add new element to listview

Main form - Modify To modify a record let’s create a handler function to double click event of the listview. When a row is double clicked, we will open it to be edited. To achieve this, create a event handler function for double click event of listview.

At least one row is selected. Main form - Modify Add following code to handler function. At least one row is selected. Selected element Record to be modified If OK button is pressed Modify record

Main form - Delete To delete selected row, create a handler function for Sil button.

Main form - Delete Add following code to handler function. At least one element is selected If user is sure of what she is doing Remove selected element from listview

Main Menu Main menu is the control that resides upper section of the form. It provides easy access for frequently used operations.

Adding Main Menu MainMenu is added to the form by dragging and dropping from.

Adding new element to the Main Menu To add new items to the MainMenu, just type the name of the element to the areas written “Type Here” in the MainMenu.

Making menu element operational Just double click on the menu element to create handler function to their default events. You may enter whatever code you wanted to the handler function.

Writing to a file In C# language System.IO namespace is used for file operations. To enable Turkish language support, it is suggested to use “StreamWriter” class. To get file name to be written from user, you may use SaveFileDialog class.

Example Add following code to the click event handler function of the MainMenu element named “Save”.

SaveFileDialog SaveFileDialog used used for asking to user which file will be selected for write operation. Create SaveFileDialog object Filter definition Show dialog box and decide whether OK button is pressed.

StreamWriter This object is used for writing to a file. Its constructor accepts two arguments, one for file name to be written, one for “encoding”which decides code page. WriteLine function write data to the file. Add Turkish support Create StreamWriter object Write a line to the file Create special formatted strings Get data from listview

Try the program – New record

Try the program – New record

Try the program – Modify a record

Try the program – Modify a record

Try the program – Saving to a file

Try the program – Saving to a file

Try the program – Saving to a file

Read from file As in writing file, System.IO name space includes classes which are used fro reading from a file. Use “StreamReader” class for Turkish language support. Use OpenFileDialog class to ask user which file is meant to be read.

Example Add following code to the click event handler function of the “Read from file” menu item.

OpenFileDialog OpenFileDialog is used for selecting the file name to be opened for reading. Define filter Create OpenFileDialog object Show dialog box and decide whether OK button is pressed.

StreamReader This is the object that reads from a file. Its constructor accepts two arguments, one for file name to be read, one for “encoding” which decides code page. ReadLine function reads one line from file. Read with Turkish support Create StreamReader Read a line from file Add read data to the listview

Try the program – Read from a file

Try the program – Read from a file

Try the program – Read from a file