458.01K
Категория: ПрограммированиеПрограммирование

Dialog Boxes

1.

Dialog Boxes.

2.

OpenFileDialog , SaveFileDialog
OpenFileDialog and SaveFileDialog have a number of common properties, among which
are the following:
DefaultExt: sets the file extension, which is added by default, if the user entered a file
name without an extension
AddExtension: if set to true, adds an extension to the file name when it is empty. The
extension is taken from the DefaultExt or Filter property
CheckFileExists: if it is true, it checks the existence of a file with the specified name
CheckPathExists: if it is true, it checks the existence of the path to the file with the
specified name
FileName: returns the full name of the file selected in the dialog box

3.

Let's take a look at both dialog boxes. Add a textBox1 and two
buttons: button1 and button2 to the form. Also, we drag the
OpenFileDialog and SaveFileDialog components from the toolbar.
After the addition, they will appear at the bottom of the form
designer. As a result, the form will look something like this:

4.

5.

6.

FontDialog , ColorDialog
To select the shift and its parameters, use FontDialog. To use it, move the component
from the Toolbar to the form. And let the button have a button1 on the form. Then in the
form code, write the following:

7.

ColorDialog allows you to choose the color settings. Also, transfer it from the Toolbar to the
form. And change the form code:

8.

Example №1.
Create an application to show the different types of MessageBox messages.
Create an InputBox message similar to VisualBasic. Use ColorDialog to change
the color of the form, FontDialog to change the text font in label and
OpenFileDialog to load image to PictureBox.
Crete new Windows Forms Application Project and design the form as shown:
English     Русский Правила