0% found this document useful (0 votes)
24 views28 pages

Dialog Boxes: Pemrograman Visual by Kartika Firdausy Pvisual@ee - Uad.ac - Id Blog - Uad.ac - Id/kartikaf

The document discusses various common dialog boxes in Windows applications, including open, save, print, font, color, and date/time picker dialog boxes. It explains how each dialog box allows users to perform routine operations like opening, saving, printing, and formatting documents. It provides details on how to implement these dialog boxes in .NET applications using classes like OpenFileDialog, PrintDialog, FontDialog, and DateTimePicker. It also discusses controls like web browsers, picture boxes, and how to handle events associated with user interactions.

Uploaded by

JUGI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views28 pages

Dialog Boxes: Pemrograman Visual by Kartika Firdausy Pvisual@ee - Uad.ac - Id Blog - Uad.ac - Id/kartikaf

The document discusses various common dialog boxes in Windows applications, including open, save, print, font, color, and date/time picker dialog boxes. It explains how each dialog box allows users to perform routine operations like opening, saving, printing, and formatting documents. It provides details on how to implement these dialog boxes in .NET applications using classes like OpenFileDialog, PrintDialog, FontDialog, and DateTimePicker. It also discusses controls like web browsers, picture boxes, and how to handle events associated with user interactions.

Uploaded by

JUGI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Dialog Boxes

Pemrograman Visual
by Kartika Firdausy
[email protected]
blog.uad.ac.id/kartikaf
kartikaf.wordpress.com

The Open Dialog Box


When creating an application, if it is a word processor, after
opening the application, it may display a white empty
area in which the user can start typing.
If the user is working on a spreadsheet, he or she may start
typing numbers and performing calculations.
In the same way, a user who is facing a graphics application
would start drawing in it.
The object that a user would be using is called a document.

After working on it for a while, there are some other


automatic ideas that come in the mind of a user.
One would lead to saving the document.
Another would consist of printing it.
All these routine operations should be available for the user
to use them.
This aspect of the application is taken care of by the person
who created the application; this is because not every
application allows a user to save or to point its
documents.
If you want these operations to be possible, you must
(explicitly) provide them.

Windows Common Dialog Boxes

To support the various operations of saving a document, opening an


existing document, printing a document, setting up printing, etc, Microsoft
Windows provides a series of standard dialog boxes that are available
almost regardless of the programming environment you are using to
develop your application.

These common dialog boxes are stored in DLLs that ship with the operating
system but they may be provided in a raw format.

For this reason, except if programming in Win32, the programming


environment you use provides a customized and friendlier technique of
adding these dialog boxes to your application.

In the same way, the .NET Framework provides its own implementation of
these ready-made dialog boxes in a manner that makes it easier to
implement them.

Windows Common Dialog Boxes

To use a standard Windows dialog box, from the


Toolbox, click the button that corresponds to the dialog
box you want to add and click anywhere on the form.

The position of the control on the form has no


importance because it is only a representative: it will not
appear when the form is running.
Once the desired dialogs icon is on the form, place a
button on the form or create a menu item that will be
used to call the dialog box.

The Open File Dialog Box


Besides saving files, another common operation performed by users
consists of opening files.
To support this operation, Microsoft Windows provides a standard
object: the Open File dialog box

Open File Dialog Box Creation

To provide file opening support, the


.NET Framework provides the
OpenFileDialog class which is derived
from the FileDialog class that in fact
provides most of its functionality. The
easiest way to use it is to click the
OpenFileDialog button from the
Toolbox and click the form.

You can click anywhere on the form


because the OpenFileDialog object
would not be seen at run time. After
placing it on the form, you can use the
Properties window to configure it.

Characteristics of an Open File Dialog Box


If you want a default file to be specified when the dialog
box comes up, you can specify this in the FileName
property of the Properties window.
If you need to use this property, you should make sure
the file can be found. If the file is located in the same
folder as the application, you can provide just its name. If
the file is located somewhere else in the hard drive, you
should provide its complete path.

Characteristics of an Open File Dialog Box


To make your application
more effective, you should
know what types of files your
application can open.
This is taken care of by
specifying a list of extensions
for the application. To control
the types of files that your
application can open, specify
their extensions using the
Filter Property.

Characteristics of an Open File Dialog Box

Like the SaveFileDialog control, the


default extension is the one the dialog box
would first filter during file opening.
If you want the Open dialog box to easily
recognize a default type of file when the
dialog box opens, you can specify the
extension's type using the DefaultExt
property.

Print Dialog Box


Another operation users perform on a file is to print it.
Printing is the ability to render, on paper, the result of a
control's content or the contents of various controls.
This is performed using an external device called a
peripheral.
To do this, users need access to a printer device.

Print Dialog Box

Print Dialog Box


The Print dialog box allows a user to select a printer if more than
one are available.
The user can decide either to print the whole document, to print a
range of pages, or to print a portion of the document that was
previously selected.
The user can also decide on the number of copies to print from the
document, the range specified, or the selected portion.
Furthermore, the user can access the particular characteristics of the
selected printer and specify how the printer should perform the job.
For example, if the selected printer can print in color and the
document is in color but the user wants to print in black and white,
he or she can specify this using the Properties button.

Print Dialog Box


To provide the users with
the ability to customize
printing through the Print
dialog box, you can add a
PrintDialog object
from the Toolbox to your
form.

Page Setup Dialog Box

Page Setup Dialog Box


To provide a Page Setup to your
application, you can use the
PageSetupDialog button
from the Toolbox.
The PageSetupDialog control is
based on the PageSetupDialog
class which derives from the
CommonDialog class.

Font Dialog Box


The Font dialog box allows
a user to select a font and
apply it to a text-based
document, paragraph or
word.
To create a Font dialog box
in MS .Net application, you
can use the FontDialog
class.

Font Dialog Box


The Script combo box
allows the user to
specify an alphabetic
category.
The options are
Western (the default for
a US-English
computer), Greek,
Turkish, Central
European, and Cyrillic.

Making Color Dialog Box Available

To provide the Color dialog box


to your application, on the
Toolbox, you can click the
ColorDialog button and
click anywhere on the form.

Color Dialog Box


To provide the selection of colors on Microsoft Windows
applications, the operating system provides a common dialog box
the user can click the Define Custom Colors >> button to expand
the dialog box:

Picture Box
A picture box is a rectangular
object that can serve different
purposes.
It can be used to host or hold
other controls, it can be used as
a drawing board instead of
drawing directly on a form, it
can be used to display a picture
on an application, it can also be
used for aesthetic reasons.

Picture Box

Memilih gambar yang ditampilkan


pertama kali properti Image

The Date and Time Picker


The Date and Time Picker is a
control that allows the user to select
either a date or a time value.
One of the advantages of the Date
and Time Picker control is that it
allows the user to select a time or a
date value instead of typing it. This
tremendously reduces the
likelihood of mistakes.
To create a Date or Time Picker
control, add a DateTimePicker
control to a form or other
container.

The Date and Time Picker


The Date and Time Picker is a control that allows the user to select
either a date or a time value. This control provides two objects in
one:
After adding a DateTimePicker control to a container, to make it a
Timer Picker control, you can change its Format property to a Time
value.

Web Browser
Pada Toolbox
pilih button
WebBrowser

Event
KeyDown pada textBoxAlamat

Navigated pada webBrowser1

Event handler
private: System::Void buttonOK_Click(System::Object^ sender, System::EventArgs^ e)
{
webBrowser1->Navigate(textBoxAlamat->Text);
}
private: System::Void textBoxAlamat_KeyDown(System::Object^ sender,
System::Windows::Forms::KeyEventArgs^ e)
{
if (e->KeyCode == System::Windows::Forms::Keys::Enter
&& !textBoxAlamat->Text->Equals("")) {
webBrowser1->Navigate(textBoxAlamat->Text);
}
}
private: System::Void webBrowser1_Navigated(System::Object^ sender,
System::Windows::Forms::WebBrowserNavigatedEventArgs^ e) {
textBoxAlamat->Text = webBrowser1->Url->ToString();

You might also like