You are on page 1of 21

NUMERIC UP DOWN

AND
OPEN DIALOG
INTRODUCTION
A NumericUpDown control allows a user to provide a spin (up/down)
interface to move through predefined numbers using up and down
arrows.
NumericUpDown represents a numeric textbox that can be
increased or decreased in value. With many properties and event
handlers, the NumericUpDown control is ideal for interfaces where
a number is entered or adjusted.
STEPS TO CREATE THE
COMPONENT
Creating a NumericUpDown control is a work of creating an
instance of NumericUpDown class, setting its properties and adding
it to the form.

First step to create a NumericUpDown control is to create an


instance of NumericUpDown class.
The next step is to set its properties.
Finally, add to the form.
SAMPLE CODE
BASIC PROPERTIES OF
NUMERICUPDOWN
 NumericUpDown. Value :- sets or gets the value assigned to the
component.
 NumericUpDown. Minimum :- sets the minimum value.
 NumericUpDown. Maximum :- sets the maximum value.
 NumericUpDown. Increment :- used to change the value to
increment or decrement the spin.
 NumericUpDown. Font :- sets the font of the text.
 NumericUpDown. Enabled :- enables/disables the component.
CONT.
 NumericUpDown. DecimalPlaces :- Specifies the number of digits
displayed after the decimal symbol.
 NumericUpDown. Parent :- Sets or gets the parent container of the
control.
 NumericUpDown. Size :- Sets or gets the width and height of the
control.
 NumericUpDown. Visible :- Sets or gets the value indicating
whether the control is displayed.
 NumericUpDown. ThousandsSeparator :- displays a
ThousandsSeparator (comma) on the numbers displayed on the
control.
This example shows how to set the minimum and maximum values for three
NumericUpDown controls day, month, and year together with the output.
EVENTS FOR
NUMERICUPDOWN
There are various events but the most common is the
ValueChanged event. It occurs when we try to change the value of
the NumericUpDown control by clicking the arrows or pressing the
up or down arrow keys. The following example shows how to use
this event to display the value of the day NumericUpDown control
on a message box.
EXAMPLE (CONT.)
CONT.
Other events…
 KeyDown,
 KeyUp,
 KeyPress,
 MouseClick,
 SizeChanged,
 Leave, etc.
OPEN FILE DIALOGUE
DESCRIPTION
An OpenFileDialog in C# is a control that allows us to browse and
select files on a computer in an application
A typical Open File Dialog looks like the next figure where you can
see Windows Explorer like features to navigate through folders and
select a file.
HOW TO CREATE AN OPEN
FILE DIALOGUE
We can create the OpenFileDialogue in two ways :
Dynamically(Run Time) or at Design Time
To create an OpenFileDialog control at design-time, you simply drag and drop
an OpenFileDialog control from Toolbox to a Form in Visual Studio.
Adding an OpenFileDialog to a Form adds following two lines of code.
private System.Windows.Forms.OpenFileDialog openFileDialog1;  
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
CONT.
Creating a OpenFileDialog control at run-time is merely a work of
creating an instance of OpenFileDialog class, set its properties and
add OpenFileDialog class to the Form controls.
First step to create a dynamic OpenFileDialog is to create an
instance of OpenFileDialog class. The following code snippet
creates an OpenFileDialog control object.
OpenFileDialog openFileDialog1 = new OpenFileDialog();  
ShowDialog method displays the OpenFileDialog.
openFileDialog1.ShowDialog(); 
SETTING OPENFILEDIALOG
PROPERTIES
After you place an OpenFileDialog control on a Form, the next step
is to set properties.
The easiest way to set properties is from the Properties Window.
You can open Properties window by pressing F4 or right click on a
control and select Properties menu item. The Properties window
looks like the next figure .
PROPERTIES
Title
CheckFileExists
CheckPathExists
Multiselect
Filter
InitialDirectory
FileName
SafeFileName
ShowHelp
ShowReadOnly
ReadOnlyChecked
METHODS
showDialog()
OpenFile()
EVENTS
FileOK
HelpRequest
GROUP MEMBERS ---
SECTION A
1. Abdulhafiz Helil
2. Ahmed Hassen
3. Ammar Jemal
4. Biniyam Edmealem

You might also like