session 5 bai 5 ve winform

24
Session 5 Slide 1 of 13 06/16/22 Dialog Boxes

Upload: mrtom16071980

Post on 25-May-2015

166 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Session 5 Bai 5 ve winform

Session 5

Slide 1 of 13

04/12/23

Dialog Boxes

Page 2: Session 5 Bai 5 ve winform

Slide 2 of 26

04/12/23

Module Introduction+ A dialog box is a special window, which can be used to interact with the user and display information.

+ It acts as a container that can hold various controls to retrieve information.

+ Dialog boxes are divided into two categories : - Common dialog boxes are system-defined dialog boxes - Custom dialog boxes are user-defined dialog boxes.

Page 3: Session 5 Bai 5 ve winform

Slide 3 of 26

04/12/23

A dialog box is a window that allows you to collect and display related information using various controls. Some of the dialog boxes that you have used in Windows are Save As, Color, Print and Page Setup.

Introduction to Dialog Boxes

Page 4: Session 5 Bai 5 ve winform

Slide 4 of 26

04/12/23

ElementsA dialog box consists of:• Title bar displaying caption and the close icon• Instruction text informing what the user should do (optional)• Content with controls to select or display information• Action area having buttons and link labels• Footnote area explaining about the window (optional)

Page 5: Session 5 Bai 5 ve winform

Slide 5 of 26

04/12/23

Features

A dialog box is different from forms because of some basic features. These are:+ Non-resizable: A dialog box is not resizable and cannot be maximized or minimized.+ Usually Modal: A dialog box is usually of modal type. This means that the user is not allowed to focus on any other window until the dialog box is closed.+ Common Set of Buttons and Icons: a dialog box consists of some standard buttons such as OK and Cancel.It also consists of the Help and Close icons on its top-right corner.

Page 6: Session 5 Bai 5 ve winform

Slide 6 of 26

04/12/23Modal Dialog Box

There are two types of dialog boxes namely : modal and modeless.+ A modal dialog box does not allow the user to activate any other window in the application unless the dialog box is closed. + A modeless dialog box allows user to focus and work with the same application without closing the dialog box.

Page 7: Session 5 Bai 5 ve winform

Slide 7 of 26

04/12/23

Common and Custom Dialog Boxes

+ Common dialog boxes are system-defined dialog boxes such as Open, Save and Print. These dialog boxes are reusable and hence can be used across various applications.+ Custom dialog boxes are user-defined dialog boxes. These dialog boxes are useful when the system-defined dialog boxes do not fulfill certain requirements.

Page 8: Session 5 Bai 5 ve winform

Slide 8 of 26

04/12/23

"CommonDialog" Class The CommonDialog class is the base class for all common dialog boxes. This class exists in the System.Windows.Forms namespace.

Page 9: Session 5 Bai 5 ve winform

Slide 9 of 26

04/12/23

"ColorDialog" Component The ColorDialog component is a dialog box that allows you to select system-defined colors from the color palette.

Page 10: Session 5 Bai 5 ve winform

Slide 10 of 26

04/12/23

"ColorDialog" Class

Page 11: Session 5 Bai 5 ve winform

Slide 11 of 26

04/12/23

"FontDialog" Component The FontDialog component allows you to select different fonts that are installed in the system.

Page 12: Session 5 Bai 5 ve winform

Slide 12 of 26

04/12/23

"FontDialog" Class

Page 13: Session 5 Bai 5 ve winform

Slide 13 of 26

04/12/23

"OpenFileDialog" and "SaveFileDialog" ComponentsThe OpenFileDialog and SaveFileDialog are the most commonly used dialog boxes in applications. The OpenFileDialog component allows you to open a file and the SaveFileDialog component allows you to save a file.

Page 14: Session 5 Bai 5 ve winform

Slide 14 of 26

04/12/23"OpenFileDialog" Class

Page 15: Session 5 Bai 5 ve winform

Slide 15 of 26

04/12/23

"SaveFileDialog" Class

Page 16: Session 5 Bai 5 ve winform

Slide 16 of 26

04/12/23

"PageSetupDialog" Component The PageSetupDialog component is a system-defined dialog box, which allows the user to set the page layout for printing. It provides various options such as the border and margin adjustments, headers and footers, and portrait and landscape orientation for the page to be printed.

Page 17: Session 5 Bai 5 ve winform

Slide 17 of 26

04/12/23

"PageSetupDialog" Class

Page 18: Session 5 Bai 5 ve winform

Slide 18 of 26

04/12/23

"PrintDialog" Component The PrintDialog component is a system-defined dialog box that allows you to print the documents.

Page 19: Session 5 Bai 5 ve winform

Slide 19 of 26

04/12/23

"PrintDialog" Class

Page 20: Session 5 Bai 5 ve winform

Slide 20 of 26

04/12/23

"PrintPreviewDialog" Control The PrintPreviewDialog control is used to display the way a document will appear when printed.

Page 21: Session 5 Bai 5 ve winform

Slide 21 of 26

04/12/23

"PrintPreviewDialog" Class

Page 22: Session 5 Bai 5 ve winform

Slide 22 of 26

04/12/23User-Defined Dialog Boxes A system-defined dialog box does not always fulfill the requirements of the developers and users. In such cases, a developer needs to create custom dialog boxes to fulfill the requirements. To do so, you can convert a form into a user-defined dialog box.

To create a user-defined dialog box:

+ The FormBorderStyle property of the form should be set to FixedDiaiog. + The ControlBox, MinimizeBox, and MaximizeBox properties should be set to False. + The form must provide the OK and Cancel buttons to either close the dialog box or cancel any tasks within the dialog box.+ The AcceptButton property of the form should be used to set the OK button.+ The CancelButton property of the form should be used to set the Cancel button.

Page 23: Session 5 Bai 5 ve winform

Slide 23 of 26

04/12/23

Page 24: Session 5 Bai 5 ve winform

Slide 24 of 26

04/12/23

Retrieving Information from a Dialog Box The form that displays the dialog box can retrieve the result of that dialog box by referencing its DialogResult property.

"DialogResult" Enumeration