SlideShare a Scribd company logo
1 of 82
PROGRAMMING USING C#.NET
R.SARASWATHI
SRI AKILANDESWARI WOMENS COLLEGE
UNIT - II: WINDOWS FORMS
• Windows Forms – Form Class – Common
Operations on Forms – Creating a
Message Box –Handling Events – Mouse
Events – Keyboard Events – Common
Controls in Windows Forms – Label –
TextBox – Button – Combo Box – List
Box – Check Box – Radio Button – Group
Box – Picture Box – Timer – Open File
Dialog – Save File Dialog – Font Dialog –
Color Dialog – Print Dialog – Tree View –
Menu.
Windows Forms
• A windows form application is an
application, which is designed to run
on a computer.
• It will not run on web browser
because then it becomes a web
application.
INTRODUCTION
• A Windows forms application is one that runs on
the desktop computer. A Windows forms
application will normally have a collection of
controls such as labels, textboxes, list boxes, etc.
INTRODUCTION
• Step 1) The first step involves the creation of
a new project in Visual Studio. After
launching Visual Studio, you need to choose
the menu option New->Project.
INTRODUCTION
• Step 2) The next step is to choose the project
type as a Windows Forms application. Here
we also need to mention the name and
location of our project.
INTRODUCTION
INTRODUCTION
• A Form application called Forms1.cs.
This file will contain all of the code for
the Windows Form application.
• The Main program called Program.cs is
default code file which is created when a
new application is created in Visual
Studio.
• This code will contain the startup code
for the application as a whole.
INTRODUCTION
INTRODUCTION
INTRODUCTION
INTRODUCTION
INTRODUCTION
INTRODUCTION
Creating a Message Box
• C# MessageBox in Windows Forms
displays a message with the given text
and action buttons.
• Can also use MessageBox control to
add additional options such as a
caption, an icon, or help buttons.
Creating a Message Box
• Message Box is a class in the
“Systems.Windows.Forms” Namespace
and the assembly it is available is
“System.Windows.Forms.dll”.
• The show method available in the class
is used to display the message along
with action buttons.
• The action buttons can be anything
ranging from Yes to No, Ok to Cancel.
Creating a Message Box
• string msg = "Test";
MessageBox.Show(msg);
• string message = "Simple MessageBox";
string title = "Title";
MessageBox.Show(message, title);
Types of Show Methods
Syntax Use
MessageBox.Show(String)
It will display only the message box with the string that is
passed. An ok button is also present to close the dialog.
Example:Messagebox.Show(“Test”)
MessageBox.Show( String, String)
It will display only the message box with the string that is passed
as first parameter. The second parameter is the title of the
Message Box. An ok button is also present to close the dialog.
Example:MessageBox.Show( “Message”, ”Title”).
MessageBox.Show( String,String,
MessageBoxButtons)
It will display the message box with the supplied text, title and
the corresponding buttons to be displayed on the Message Box.
For eg the below will display Yes and No buttons.
MessageBox.Show( "Message”, "Title",
MessageBoxButtons.YesNo);
Types of Show Methods
Show(String, String, MessageBoxButtons,
MessageBoxIcon)
It will display the message box with the supplied text, title and the corresponding buttons to
be displayed on the Message Box. It will also display the icon that is specified before the
text.
For eg the below will display Yes and No buttons with a question mark in front of message.
MessageBox.Show( "Message”, "Title", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
Show(String, String, MessageBoxButtons,
MessageBoxIcon, MessageBoxDefaulButton)
It will display the message box with the supplied text, title and the corresponding buttons to
be displayed on the Message Box. It will also display the icon that is specified before the
text. The last parameter denotes which button must be selected by default on load.
For eg the below will display Yes and No buttons with a question mark in front of message.
MessageBox.Show( "Message”, "Title", MessageBoxButtons.YesNo,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
Show(String, String, MessageBoxButtons,
MessageBoxIcon, MessageBoxDefaulButton,
MessageBoxOptions)
It will display the message box with the supplied text, title, and the corresponding buttons
to be displayed on the Message Box. It will also display the icon that is specified before the
text. The last parameter denotes which button must be selected by default on load and the
contents of the messagebox will be right-aligned.
For eg the below will display Yes and No buttons with a question mark in front of message.
MessageBox.Show( "Message”, "Title", MessageBoxButtons.YesNo,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2,
MesageBoxOptions.RightAlign, true);
Types of MessageBox Buttons
• OK: It is defined as MessageBoxButtons.OK
• OK and Cancel: It is defined as
MessageBoxButtons.OkCancel.
• Abort Retry and Ignore: It is defined as
MessageBoxButtons.AbortRetryIgnore.
• Yes No and Cancel: It is defined as
MessageBoxButtons.YesNoCancel.
• Yes and No: It is defined as MessageBoxButtons.YesNo.
• Retry and Cancel: It is defined as
MessageBoxButtons.RetryCancel.
Types of MessageBox Buttons
• None: No icons are displayed in the Message box.
• Hand: A hand icon is displayed. It is defined as
MessageBoxIcon.Hand.
• Question: A question mark is displayed. It is
defined as MessageBoxIcon.Question.
• Exclamation: An exclamation mark is displayed.
It is defined as MessageBoxIcon.Exclamation.
Types of MessageBox Buttons
• Asterisk: An asterisk symbol is displayed. It is defined
as MessageBoxIcon.Asterisk.
• Stop: A stop icon is displayed. It is defined as
MessageBoxIcon.Stop.
• Error: An error icon is displayed. It is defined as
MessageBoxIcon.Error.
• Warning: A warning icon is displayed. It is defined as
MessageBoxIcon.Warning.
• Information: An info symbol is displayed. It is defined
as MessageBoxIcon.Information.
Example
string message = "Do you want to abort this operation?";
string title = "Close Window";
MessageBoxButtons buttons = MessageBoxButtons.AbortRetryIg
nore;
DialogResult result = MessageBox.Show(message, title, buttons,
MessageBoxIcon.Warning);
if (result == DialogResult.Abort) {
this.Close();
}
elseif(result == DialogResult.Retry) {
// Do nothing
}
else {
// Do something
}
OUTUT
Handling Events
• Events are user actions such as key
press, clicks, mouse movements, etc.,
or some occurrence such as system
generated notifications.
• Applications need to respond to events
when they occur. For example,
interrupts. Events are used for inter-
process communication.
Handling Events
• An event can be declared in two steps:
– Declare a delegate.
– Declare a variable of the delegate with event keyword
public delegate void Notify(); // delegate
public class ProcessBusinessLogic
{ public event Notify ProcessCompleted; // event
}
Label
• A Label control is used as a display
medium for text on Forms. Label
control does not participate in user
input or capture mouse or keyboard
events.
• There are two ways to create a control.
Label
Design-Time
• Step 1: Create a windows form as shown in the
below image:
Visual Studio -> File -> New -> Project ->
WindowsFormApp
• Step 2: Drag the Label control from the ToolBox
and drop it on the windows form. You are
allowed to place a Label control anywhere on the
windows form according to your need.
• Step 3: After drag and drop you will go to the
properties of the Label control to set the
properties of the Label according to your need.
Label
• 2. Run-Time: It is a little bit trickier than the
above method. In this method, you can set create
your own Label control using the Label class.
Steps to create a dynamic label:
• Step 1: Create a label using the Label()
constructor is provided by the Label class.
Label mylab = new Label();
• Step 2: After creating Label, set the properties of
the Label provided by the Label class.
mylab.Text = "GeeksforGeeks";
• Step 3: And last add this Label control to form
using Add() method.
this.Controls.Add(mylab);
Label
namespace WindowsFormsApp18 {
public partial class Form1 : Form {
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Creating and setting the label
Label mylab = new Label();
mylab.Text = "GeeksforGeeks";
mylab.Location = new Point(222, 90);
mylab.AutoSize = true;
mylab.Font = new Font("Calibri", 18);
mylab.ForeColor = Color.Green;
mylab.Padding = new Padding(6);
// Adding this control to the form
this.Controls.Add(mylab);
}
}
}
TextBox
• A TextBox control is used to display, or accept as
input, a single line of text.
• This control has additional functionality that is
not found in the standard Windows text box
control, including multiline editing and password
character masking.
• A text box object is used to display text on a form
or to get user input while a C# program is
running. In a text box, a user can type data or
paste it into the control from the clipboard.
TextBox
string var;
var = textBox1.Text;
TextBox
• Step 1 : Create a textbox using the TextBox()
constructor provided by the TextBox class.
TextBox Mytextbox = new TextBox();
• Step 2 : After creating TextBox, set the
properties of the TextBox provided by the
TextBox class.
Mytextbox.Location = new Point(187, 51);
• Step 3 : And last add this textbox control to
from using Add() method.
this.Controls.Add(Mytextbox);
TextBoxusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace my {
public partial class Form1 : Form {
public Form1()
{ InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) {
Label Mylablel = new Label();
Mylablel.Location = new Point(96, 54);
Mylablel.Text = "Enter Name";
Mylablel.AutoSize = true;
Mylablel.BackColor = Color.LightGray;
this.Controls.Add(Mylablel);
TextBox Mytextbox = new TextBox();
Mytextbox.Location = new Point(187, 51);
Mytextbox.BackColor = Color.LightGray;
Mytextbox.ForeColor = Color.DarkOliveGreen;
Mytextbox.AutoSize = true;
Mytextbox.Name = "text_box1";
// Add this textbox to form
this.Controls.Add(Mytextbox);
} }}
TextBox
Button
• A button is a control, which is an interactive component
that enables users to communicate with an application.
• The Button class inherits directly from the ButtonBase
class.
• A Button can be clicked by using the mouse, ENTER
key, or SPACEBAR if the button has focus.
Button
• button1.Text = "Click Here";
• button1.Image =
Image.FromFile("C:testimage.jpg");
Button
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication21 {
public partial class Form1 : Form
{ public Form1()
{ InitializeComponent(); }
private void button1_Click(object sender, EventArgs
e)
{
MessageBox.Show("Dot Net Perls says hello.", "How
is your day going?");
} } }
Button
• There are several events which we can use with
buttons.
• Events are some conditional checks to perform
the specific functionalities when user will do
something specific.
• C# programming language provides a couple of
events which you can use with button and we
are going to implement some of them which are
commonly used..
• Click Event
• Text Changed Event
• MouseHover Event
• MouseLeave Event
Combo Box
• A ComboBox displays a text box
combined with a ListBox, which enables
the user to select items from the list or
enter a new value.
Combo Box
• The user can type a value in the text
field or click the button to display a drop
down list.
• User can add individual objects with the
Add method.
• user can delete items with the Remove
method or clear the entire list with the
Clear method.
Combo Box
add a item to combobox
comboBox1.Items.Add("Sunday");
comboBox1.Items.Add("Monday");
comboBox1.Items.Add("Tuesday");
retrieve value from ComboBox
string var;
var = comboBox1.Text;
Or
var item =
this.comboBox1.GetItemText(this.comboBox1.SelectedItem);
MessageBox.Show(item);
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.Items.Add("weekdays");
comboBox1.Items.Add("year");
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox2.Items.Clear();
if (comboBox1.SelectedItem == "weekdays")
{
comboBox2.Items.Add("Sunday");
comboBox2.Items.Add("Monday");
comboBox2.Items.Add("Tuesday");
}
else if (comboBox1.SelectedItem == "year")
{
comboBox2.Items.Add("2012");
comboBox2.Items.Add("2013");
comboBox2.Items.Add("2014");
} } }}
Output
List Box
• The ListBox control enables you to display a list
of items to the user that the user can select by
clicking.
List Box
Setting ListBox Properties
• set ListBox properties by using Properties Window. In
order to get Properties window you can Press F4 or by
right-clicking on a control to get the "Properties" menu
item.
List Box
listBox1.Items.Add("Sunday");
listBox1.Items.Insert(0, "First");
listBox1.Items.Insert(1, "Second");
listBox1.Items.Insert(2, "Third");
listBox1.Items.Insert(3, "Forth");
string item =
listBox1.GetItemText(listBox1.SelectedItem);
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
listBox1.Items.Add("Sunday");
listBox1.Items.Add("Monday");
listBox1.Items.Add("Tuesday");
listBox1.Items.Add("Wednesday");
listBox1.Items.Add("Thursday");
listBox1.Items.Add("Friday");
listBox1.Items.Add("Saturday");
listBox1.SelectionMode = SelectionMode.MultiSimple;
}
private void button1_Click(object sender, EventArgs e)
{
foreach (Object obj in listBox1.SelectedItems )
{
MessageBox.Show(obj.ToString ());
}}}}
Check Box
• CheckBoxes allow the user to make multiple selections from a number of options.
• CheckBox to give the user an option, such as true/false or yes/no. You can click a
check box to select it and click it again to deselect it.
• The CheckBox control can display an image or text or both. Usually CheckBox
comes with a caption, which you can set in the Text property.
Check Box
• CheckBox control ThreeState property
to direct the control to return the
Checked, Unchecked, and
Indeterminate values. User
• need to set the check boxs ThreeState
property to True to indicate that you
want it to support three states.
checkBox1.ThreeState = true;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{ InitializeComponent(); }
private void button1_Click(object sender, EventArgs e)
{
string msg = "";
if (checkBox1.Checked == true)
{ msg = "net-informations.com"; }
if (checkBox2.Checked == true)
{ msg = msg + " vb.net-informations.com"; }
if (checkBox3.Checked == true)
{ msg = msg + " csharp.net-informations.com"; }
if (msg.Length > 0)
{ MessageBox.Show (msg + " selected "); }
else { MessageBox.Show ("No checkbox selected"); }
checkBox1.ThreeState = true; } } }
Radio Button
• A radio button or option button enables the user to select a single
option from a group of choices when paired with other RadioButton
controls.
• When a user clicks on a radio button, it becomes checked, and all
other radio buttons with same group become unchecked.
Radio Button
• The RadioButton control can display text, an Image, or
both. Use the Checked property to get or set the state of
a RadioButton.
radioButton1.Checked = true;
• The radio button and the check box are used for
different functions.
• Use a radio button when you want the user to choose
only one option.
• When you want the user to choose all appropriate
options, use a check box.
• Like check boxes, radio buttons support a Checked
property that indicates whether the radio button is
selected.
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{ public partial class Form1 : Form
{ public Form1()
{ InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e)
{
radioButton1.Checked = true;
}
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked == true)
{ MessageBox.Show ("You are selected Red !! "); return; }
else if (radioButton2.Checked == true)
{ MessageBox.Show("You are selected Blue !! ");
return; }
else
{ MessageBox.Show("You are selected Green !! ");
return; } } } }
Group Box
• A GroupBox control is a container control used to group
similar controls.
• A GroupBox control is a container control that is used
to place Windows Forms child controls in a group.
• The purpose of a GroupBox is to define user interfaces
where we can categorize related controls in a group.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp45 {
public partial class Form1 : Form {
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender,
EventArgs e)
{
// Creating and setting
// properties of the GroupBox
GroupBox box = new GroupBox();
box.Location = new Point(179, 145);
box.Size = new Size(329, 94);
box.Text = "Select Gender";
box.Name = "MyGroupbox";
// Adding groupbox in the form
this.Controls.Add(box);
// Creating and setting
// properties of the CheckBox
CheckBox b1 = new CheckBox();
b1.Location = new Point(40, 42);
b1.Size = new Size(49, 20);
b1.Text = "Male";
// Adding this control
// to the GroupBox
gbox.Controls.Add(b1);
// Creating and setting
// properties of the CheckBox
CheckBox b2 = new CheckBox();
b2.Location = new Point(183, 39);
b2.Size = new Size(69, 20);
b2.Text = "Female";
// Adding this control
// to the GroupBox
box.Controls.Add(b2);
}
}
}
OUTPUT
Picture Box
• The Windows Forms PictureBox control is used to
display images in bitmap, GIF , icon , or JPEG formats.
• User can set the Image property to the Image you want
to display, either at design time or at run time.
• User can programmatically change the image displayed
in a picture box, which is particularly useful when you
use a single form to display different pieces of
information.
Picture Box
pictureBox1.Image =
Image.FromFile("c:testImage.jpg");
pictureBox1.SizeMode =
PictureBoxSizeMode.StretchImage;
Picture Box
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1 {
public partial class Form1 : Form {
public Form1()
{ InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile("c:testImage.jpg");
pictureBox1.SizeMode =
PictureBoxSizeMode.StretchImage;
} } }
Timer
• C# Timer is used to implement a timer in C#.
• For example, backing up a folder every 10 minutes, or writing to a log file every
second. The method that needs to be executed is placed inside the event of the
timer.
• With the Timer Control we can raise events at a specific interval of time without
the interaction of another thread.
Timer
• Set the Interval property to 1000. The value of Interval property is in
milliseconds.
• 1 sec = 1000 milliseconds.
• By default the Enabled property of Timer Control is False.
• So before running the program we have to set the Enabled property
is True , then only the Timer Control starts its function.
Timer
• User have to use Timer Object when user
want to set an interval between events,
periodic checking, to start a process at a
fixed time schedule, to increase or
decrease the speed in an animation
graphics with time schedule etc.
• A Timer control does not have a visual
representation and works as a
component in the background.
Timer
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString();
}
}
}
Open File Dialog
• The OpenFileDialog component allows users to browse
the folders of their computer or any computer on the
network and select one or more files to open.
• The dialog box returns the path and name of the file the
user selected in the dialog box.
Open File Dialog
• The FileName property can be set
prior to showing the dialog box. This
causes the dialog box to initially
display the given filename.
• In most cases, your applications
should set the InitialDirectory, Filter,
and FilterIndex properties prior to
calling ShowDialog.
Open File Dialog
namespace WindowsFormsApplication1
{ public partial class Form1 : Form
{
public Form1()
{ InitializeComponent(); }
private void button1_Click(object sender, EventArgs e)
{ OpenFileDialog dlg = new OpenFileDialog();
dlg.ShowDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{ string fileName;
fileName = dlg.FileName;
MessageBox.Show(fileName);
} } } }
Save File Dialog
• SaveFileDialog control is used to save
a file using Windows SaveFileDialog.
Save File Dialog
SaveFileDialog saveDialog = new SaveFileDialog();
saveDialog.Title = "Save";
saveDialog.Filter = "Text Files (*.txt)|*.txt" + "|" +
"Image Files (*.png;*.jpg)|*.png;*.jpg"
+ "|" +
"All Files (*.*)|*.*";
if (saveDialog.ShowDialog() == DialogResult.OK)
{
string file = saveDialog.FileName;
}
Font Dialog
• Font dialog box represents a common dialog box
that displays a list of fonts that are currently
installed on the system.
• The Font dialog box lets the user choose
attributes for a logical font, such as font family
and associated font style, point size, effects , and
a script .
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1 {
public partial class Form1 : Form { public Form1()
{ InitializeComponent(); }
private void button1_Click(object sender, EventArgs
e)
{
FontDialog dlg = new FontDialog();
dlg.ShowDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{ string fontName;
float fontSize;
fontName = dlg.Font.Name;
fontSize = dlg.Font.Size;
MessageBox.Show(fontName + " " + fontSize );
} } } }
Color Dialog
• A C# ColorDialog control is used to
select a color from available colors
and also define custom colors.
Color Dialog
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1 {
public partial class Form1 : Form {
public Form1()
{ InitializeComponent(); }
private void button1_Click(object sender, EventArgs e)
{
ColorDialog dlg = new ColorDialog();
dlg.ShowDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
string str = null;
str = dlg.Color.Name;
MessageBox.Show (str);
} } } }
Print Dialog
• A user can use the Print dialog box to select a printer,
configure it, and perform a print job.
• Print dialog boxes provide an easy way to implement
Print and Print Setup dialog boxes in a manner
consistent with Windows standards.
• The Print dialog box includes a Print Range group of
radio buttons that indicate whether the user wants to
print all pages , a range of pages, or only the selected
text.
• The dialog box includes an edit control in which the
user can type the number of copies to print .
• By default, the Print dialog box initially displays
information about the current default printer.
Print Dialog
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Win
dowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
PrintDialog dlg = new PrintDialog();
dlg.ShowDialog();
}
}
}
Tree View
• The TreeView control contains a hierarchy of
TreeViewItem controls.
• It provides a way to display information in a
hierarchical structure by using collapsible nodes .
• The top level in a tree view are root nodes that can be
expanded or collapsed if the nodes have child nodes.
• The user can expand the TreeNode by clicking the plus
sign (+) button, if one is displayed next to the TreeNode,
or you can expand the TreeNode by calling the
TreeNode.Expand method.
• You can also navigate through tree views with various
properties: FirstNode, LastNode, NextNode, PrevNode,
NextVisibleNode, PrevVisibleNode.
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{ public partial class Form1 : Form {
public Form1()
{ InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e)
{
TreeNode tNode ; tNode = treeView1.Nodes.Add("Websites");
treeView1.Nodes[0].Nodes.Add("Net-informations.com");
treeView1.Nodes[0].Nodes[0].Nodes.Add("CLR");
treeView1.Nodes[0].Nodes.Add("Vb.net-informations.com");
treeView1.Nodes[0].Nodes[1].Nodes.Add("String Tutorial");
treeView1.Nodes[0].Nodes[1].Nodes.Add("Excel Tutorial");
treeView1.Nodes[0].Nodes.Add("Csharp.net-informations.com");
treeView1.Nodes[0].Nodes[2].Nodes.Add("ADO.NET");
treeView1.Nodes[0].Nodes[2].Nodes[0].Nodes.Add("Dataset");
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(treeView1.SelectedNode.FullPath.ToString ());
} } }
Tree View
Menu
• MainMenu is the container for the Menu
structure of the form and menus are made of
MenuItem objects that represent individual
parts of a menu.
Menu
• After drag the Menustrip on your form
you can directly create the menu items
by type a value into the "Type Here" box
on the menubar part of your form.
Menu
• If you need a seperator bar , right click on your menu then go to insert-
>Seperator.
• After creating the Menu on the form , you have to double click on each menu
item and write the programs there depends on your requirements.
Menu
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1 {
public partial class Form1 : Form
{
public Form1()
{ InitializeComponent();
}
private void menu1ToolStripMenuItem_Click(object sender,
EventArgs e)
{
MessageBox.Show("You are selected MenuItem_1");
} } }

More Related Content

What's hot

Shortcut key for windows
Shortcut key for windowsShortcut key for windows
Shortcut key for windowsTamil selvan
 
Windows 7 - Unit A
Windows 7 - Unit AWindows 7 - Unit A
Windows 7 - Unit Ajdswitzer
 
Programming Without Coding Technology (PWCT) - Encrypt/Decrypt Files using Po...
Programming Without Coding Technology (PWCT) - Encrypt/Decrypt Files using Po...Programming Without Coding Technology (PWCT) - Encrypt/Decrypt Files using Po...
Programming Without Coding Technology (PWCT) - Encrypt/Decrypt Files using Po...Mahmoud Samir Fayed
 
Programming Without Coding Technology (PWCT) - Center Window
Programming Without Coding Technology (PWCT) - Center WindowProgramming Without Coding Technology (PWCT) - Center Window
Programming Without Coding Technology (PWCT) - Center WindowMahmoud Samir Fayed
 
Programming Without Coding Technology (PWCT) - Hello Lily Sample
Programming Without Coding Technology (PWCT) - Hello Lily SampleProgramming Without Coding Technology (PWCT) - Hello Lily Sample
Programming Without Coding Technology (PWCT) - Hello Lily SampleMahmoud Samir Fayed
 
Programming Without Coding Technology (PWCT) - Adding controls to windows.
Programming Without Coding Technology (PWCT) - Adding controls to windows.Programming Without Coding Technology (PWCT) - Adding controls to windows.
Programming Without Coding Technology (PWCT) - Adding controls to windows.Mahmoud Samir Fayed
 
Programming Without Coding Technology (PWCT) - PolarCryptoLight ActiveX
Programming Without Coding Technology (PWCT) - PolarCryptoLight ActiveXProgramming Without Coding Technology (PWCT) - PolarCryptoLight ActiveX
Programming Without Coding Technology (PWCT) - PolarCryptoLight ActiveXMahmoud Samir Fayed
 
Programming Without Coding Technology (PWCT) - Add toolbar to the window
Programming Without Coding Technology (PWCT) - Add toolbar to the windowProgramming Without Coding Technology (PWCT) - Add toolbar to the window
Programming Without Coding Technology (PWCT) - Add toolbar to the windowMahmoud Samir Fayed
 
Android Dialogs Tutorial
Android Dialogs TutorialAndroid Dialogs Tutorial
Android Dialogs TutorialPerfect APK
 
computer 100 keyboar shortcuts
computer 100 keyboar shortcutscomputer 100 keyboar shortcuts
computer 100 keyboar shortcutsSreenu Munagaleti
 
Programming Without Coding Technology (PWCT) - Simple GUI Application
Programming Without Coding Technology (PWCT) - Simple GUI ApplicationProgramming Without Coding Technology (PWCT) - Simple GUI Application
Programming Without Coding Technology (PWCT) - Simple GUI ApplicationMahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210Mahmoud Samir Fayed
 
LUC/DPH/PHM/125/LNC/DPH/JUL11/05(Windows)
LUC/DPH/PHM/125/LNC/DPH/JUL11/05(Windows)LUC/DPH/PHM/125/LNC/DPH/JUL11/05(Windows)
LUC/DPH/PHM/125/LNC/DPH/JUL11/05(Windows)hazizulgyjuls
 
Windows Dialog Boxes - R.D.Sivakumar
Windows Dialog Boxes - R.D.SivakumarWindows Dialog Boxes - R.D.Sivakumar
Windows Dialog Boxes - R.D.SivakumarSivakumar R D .
 

What's hot (19)

Shortcut key for windows
Shortcut key for windowsShortcut key for windows
Shortcut key for windows
 
Windows 7 - Unit A
Windows 7 - Unit AWindows 7 - Unit A
Windows 7 - Unit A
 
Programming Without Coding Technology (PWCT) - Encrypt/Decrypt Files using Po...
Programming Without Coding Technology (PWCT) - Encrypt/Decrypt Files using Po...Programming Without Coding Technology (PWCT) - Encrypt/Decrypt Files using Po...
Programming Without Coding Technology (PWCT) - Encrypt/Decrypt Files using Po...
 
Programming Without Coding Technology (PWCT) - Center Window
Programming Without Coding Technology (PWCT) - Center WindowProgramming Without Coding Technology (PWCT) - Center Window
Programming Without Coding Technology (PWCT) - Center Window
 
Programming Without Coding Technology (PWCT) - Hello Lily Sample
Programming Without Coding Technology (PWCT) - Hello Lily SampleProgramming Without Coding Technology (PWCT) - Hello Lily Sample
Programming Without Coding Technology (PWCT) - Hello Lily Sample
 
Programming Without Coding Technology (PWCT) - Adding controls to windows.
Programming Without Coding Technology (PWCT) - Adding controls to windows.Programming Without Coding Technology (PWCT) - Adding controls to windows.
Programming Without Coding Technology (PWCT) - Adding controls to windows.
 
Programming Without Coding Technology (PWCT) - PolarCryptoLight ActiveX
Programming Without Coding Technology (PWCT) - PolarCryptoLight ActiveXProgramming Without Coding Technology (PWCT) - PolarCryptoLight ActiveX
Programming Without Coding Technology (PWCT) - PolarCryptoLight ActiveX
 
Programming Without Coding Technology (PWCT) - Add toolbar to the window
Programming Without Coding Technology (PWCT) - Add toolbar to the windowProgramming Without Coding Technology (PWCT) - Add toolbar to the window
Programming Without Coding Technology (PWCT) - Add toolbar to the window
 
03 gui 04
03 gui 0403 gui 04
03 gui 04
 
Android Dialogs Tutorial
Android Dialogs TutorialAndroid Dialogs Tutorial
Android Dialogs Tutorial
 
computer 100 keyboar shortcuts
computer 100 keyboar shortcutscomputer 100 keyboar shortcuts
computer 100 keyboar shortcuts
 
Vs c# lecture5
Vs c# lecture5Vs c# lecture5
Vs c# lecture5
 
Quick Start Guide
Quick Start GuideQuick Start Guide
Quick Start Guide
 
dr_4
dr_4dr_4
dr_4
 
Programming Without Coding Technology (PWCT) - Simple GUI Application
Programming Without Coding Technology (PWCT) - Simple GUI ApplicationProgramming Without Coding Technology (PWCT) - Simple GUI Application
Programming Without Coding Technology (PWCT) - Simple GUI Application
 
The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210
 
LUC/DPH/PHM/125/LNC/DPH/JUL11/05(Windows)
LUC/DPH/PHM/125/LNC/DPH/JUL11/05(Windows)LUC/DPH/PHM/125/LNC/DPH/JUL11/05(Windows)
LUC/DPH/PHM/125/LNC/DPH/JUL11/05(Windows)
 
Web Server Controls CS Set
Web Server Controls CS Set Web Server Controls CS Set
Web Server Controls CS Set
 
Windows Dialog Boxes - R.D.Sivakumar
Windows Dialog Boxes - R.D.SivakumarWindows Dialog Boxes - R.D.Sivakumar
Windows Dialog Boxes - R.D.Sivakumar
 

Similar to PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM

4.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.154.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.15Rajes Wari
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinFormHock Leng PUAH
 
Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Bhushan Mulmule
 
Gui builder
Gui builderGui builder
Gui builderlearnt
 
06 win forms
06 win forms06 win forms
06 win formsmrjw
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshopdhi her
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Javasuraj pandey
 
Inventory management
Inventory managementInventory management
Inventory managementRajeev Sharan
 
Creating a quiz using visual basic 6
Creating a quiz using visual basic 6Creating a quiz using visual basic 6
Creating a quiz using visual basic 6Ella Marie Wico
 
Chapter ii c#(building a user interface)
Chapter ii c#(building a user interface)Chapter ii c#(building a user interface)
Chapter ii c#(building a user interface)Chhom Karath
 
Membuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaMembuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaYusman Kurniadi
 
XMetaL Dialog Odds & Ends
XMetaL Dialog Odds & EndsXMetaL Dialog Odds & Ends
XMetaL Dialog Odds & EndsXMetaL
 
The Ring programming language version 1.5.3 book - Part 81 of 184
The Ring programming language version 1.5.3 book - Part 81 of 184The Ring programming language version 1.5.3 book - Part 81 of 184
The Ring programming language version 1.5.3 book - Part 81 of 184Mahmoud Samir Fayed
 

Similar to PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM (20)

4.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.154.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.15
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinForm
 
Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5
 
Gui builder
Gui builderGui builder
Gui builder
 
06 win forms
06 win forms06 win forms
06 win forms
 
Controls events
Controls eventsControls events
Controls events
 
SPF WinForm Programs
SPF WinForm ProgramsSPF WinForm Programs
SPF WinForm Programs
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshop
 
4.C#
4.C#4.C#
4.C#
 
Visualbasic tutorial
Visualbasic tutorialVisualbasic tutorial
Visualbasic tutorial
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
 
Inventory management
Inventory managementInventory management
Inventory management
 
Creating a quiz using visual basic 6
Creating a quiz using visual basic 6Creating a quiz using visual basic 6
Creating a quiz using visual basic 6
 
Chapter ii c#(building a user interface)
Chapter ii c#(building a user interface)Chapter ii c#(building a user interface)
Chapter ii c#(building a user interface)
 
Membuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaMembuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhana
 
XMetaL Dialog Odds & Ends
XMetaL Dialog Odds & EndsXMetaL Dialog Odds & Ends
XMetaL Dialog Odds & Ends
 
Intake 38 9
Intake 38 9Intake 38 9
Intake 38 9
 
The Ring programming language version 1.5.3 book - Part 81 of 184
The Ring programming language version 1.5.3 book - Part 81 of 184The Ring programming language version 1.5.3 book - Part 81 of 184
The Ring programming language version 1.5.3 book - Part 81 of 184
 
Introduction
IntroductionIntroduction
Introduction
 

More from SaraswathiRamalingam

Georg scheutz - Charles babbage - Saraswathi Ramalingam
Georg scheutz - Charles babbage - Saraswathi RamalingamGeorg scheutz - Charles babbage - Saraswathi Ramalingam
Georg scheutz - Charles babbage - Saraswathi RamalingamSaraswathiRamalingam
 
Dennis ritchie - SARASWATHI RAMALINGAM
Dennis ritchie - SARASWATHI RAMALINGAMDennis ritchie - SARASWATHI RAMALINGAM
Dennis ritchie - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
Arithmetic expression INFIX TO POSTFIX CONVERTION saraswathi ramalingam
Arithmetic expression INFIX TO POSTFIX CONVERTION saraswathi ramalingamArithmetic expression INFIX TO POSTFIX CONVERTION saraswathi ramalingam
Arithmetic expression INFIX TO POSTFIX CONVERTION saraswathi ramalingamSaraswathiRamalingam
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMSaraswathiRamalingam
 

More from SaraswathiRamalingam (20)

MACINTOSH
MACINTOSHMACINTOSH
MACINTOSH
 
XSL - XML STYLE SHEET
XSL - XML STYLE SHEETXSL - XML STYLE SHEET
XSL - XML STYLE SHEET
 
XML - SAX
XML - SAXXML - SAX
XML - SAX
 
DOM-XML
DOM-XMLDOM-XML
DOM-XML
 
X FILES
X FILESX FILES
X FILES
 
XML SCHEMAS
XML SCHEMASXML SCHEMAS
XML SCHEMAS
 
XML
XMLXML
XML
 
XML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITIONXML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITION
 
Georg scheutz - Charles babbage - Saraswathi Ramalingam
Georg scheutz - Charles babbage - Saraswathi RamalingamGeorg scheutz - Charles babbage - Saraswathi Ramalingam
Georg scheutz - Charles babbage - Saraswathi Ramalingam
 
Dennis ritchie - SARASWATHI RAMALINGAM
Dennis ritchie - SARASWATHI RAMALINGAMDennis ritchie - SARASWATHI RAMALINGAM
Dennis ritchie - SARASWATHI RAMALINGAM
 
Arithmetic expression INFIX TO POSTFIX CONVERTION saraswathi ramalingam
Arithmetic expression INFIX TO POSTFIX CONVERTION saraswathi ramalingamArithmetic expression INFIX TO POSTFIX CONVERTION saraswathi ramalingam
Arithmetic expression INFIX TO POSTFIX CONVERTION saraswathi ramalingam
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
 

Recently uploaded

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM

  • 1. PROGRAMMING USING C#.NET R.SARASWATHI SRI AKILANDESWARI WOMENS COLLEGE
  • 2. UNIT - II: WINDOWS FORMS • Windows Forms – Form Class – Common Operations on Forms – Creating a Message Box –Handling Events – Mouse Events – Keyboard Events – Common Controls in Windows Forms – Label – TextBox – Button – Combo Box – List Box – Check Box – Radio Button – Group Box – Picture Box – Timer – Open File Dialog – Save File Dialog – Font Dialog – Color Dialog – Print Dialog – Tree View – Menu.
  • 3. Windows Forms • A windows form application is an application, which is designed to run on a computer. • It will not run on web browser because then it becomes a web application.
  • 4. INTRODUCTION • A Windows forms application is one that runs on the desktop computer. A Windows forms application will normally have a collection of controls such as labels, textboxes, list boxes, etc.
  • 5. INTRODUCTION • Step 1) The first step involves the creation of a new project in Visual Studio. After launching Visual Studio, you need to choose the menu option New->Project.
  • 6. INTRODUCTION • Step 2) The next step is to choose the project type as a Windows Forms application. Here we also need to mention the name and location of our project.
  • 8. INTRODUCTION • A Form application called Forms1.cs. This file will contain all of the code for the Windows Form application. • The Main program called Program.cs is default code file which is created when a new application is created in Visual Studio. • This code will contain the startup code for the application as a whole.
  • 15. Creating a Message Box • C# MessageBox in Windows Forms displays a message with the given text and action buttons. • Can also use MessageBox control to add additional options such as a caption, an icon, or help buttons.
  • 16. Creating a Message Box • Message Box is a class in the “Systems.Windows.Forms” Namespace and the assembly it is available is “System.Windows.Forms.dll”. • The show method available in the class is used to display the message along with action buttons. • The action buttons can be anything ranging from Yes to No, Ok to Cancel.
  • 17. Creating a Message Box • string msg = "Test"; MessageBox.Show(msg); • string message = "Simple MessageBox"; string title = "Title"; MessageBox.Show(message, title);
  • 18. Types of Show Methods Syntax Use MessageBox.Show(String) It will display only the message box with the string that is passed. An ok button is also present to close the dialog. Example:Messagebox.Show(“Test”) MessageBox.Show( String, String) It will display only the message box with the string that is passed as first parameter. The second parameter is the title of the Message Box. An ok button is also present to close the dialog. Example:MessageBox.Show( “Message”, ”Title”). MessageBox.Show( String,String, MessageBoxButtons) It will display the message box with the supplied text, title and the corresponding buttons to be displayed on the Message Box. For eg the below will display Yes and No buttons. MessageBox.Show( "Message”, "Title", MessageBoxButtons.YesNo);
  • 19. Types of Show Methods Show(String, String, MessageBoxButtons, MessageBoxIcon) It will display the message box with the supplied text, title and the corresponding buttons to be displayed on the Message Box. It will also display the icon that is specified before the text. For eg the below will display Yes and No buttons with a question mark in front of message. MessageBox.Show( "Message”, "Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question); Show(String, String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaulButton) It will display the message box with the supplied text, title and the corresponding buttons to be displayed on the Message Box. It will also display the icon that is specified before the text. The last parameter denotes which button must be selected by default on load. For eg the below will display Yes and No buttons with a question mark in front of message. MessageBox.Show( "Message”, "Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); Show(String, String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaulButton, MessageBoxOptions) It will display the message box with the supplied text, title, and the corresponding buttons to be displayed on the Message Box. It will also display the icon that is specified before the text. The last parameter denotes which button must be selected by default on load and the contents of the messagebox will be right-aligned. For eg the below will display Yes and No buttons with a question mark in front of message. MessageBox.Show( "Message”, "Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MesageBoxOptions.RightAlign, true);
  • 20. Types of MessageBox Buttons • OK: It is defined as MessageBoxButtons.OK • OK and Cancel: It is defined as MessageBoxButtons.OkCancel. • Abort Retry and Ignore: It is defined as MessageBoxButtons.AbortRetryIgnore. • Yes No and Cancel: It is defined as MessageBoxButtons.YesNoCancel. • Yes and No: It is defined as MessageBoxButtons.YesNo. • Retry and Cancel: It is defined as MessageBoxButtons.RetryCancel.
  • 21. Types of MessageBox Buttons • None: No icons are displayed in the Message box. • Hand: A hand icon is displayed. It is defined as MessageBoxIcon.Hand. • Question: A question mark is displayed. It is defined as MessageBoxIcon.Question. • Exclamation: An exclamation mark is displayed. It is defined as MessageBoxIcon.Exclamation.
  • 22. Types of MessageBox Buttons • Asterisk: An asterisk symbol is displayed. It is defined as MessageBoxIcon.Asterisk. • Stop: A stop icon is displayed. It is defined as MessageBoxIcon.Stop. • Error: An error icon is displayed. It is defined as MessageBoxIcon.Error. • Warning: A warning icon is displayed. It is defined as MessageBoxIcon.Warning. • Information: An info symbol is displayed. It is defined as MessageBoxIcon.Information.
  • 23. Example string message = "Do you want to abort this operation?"; string title = "Close Window"; MessageBoxButtons buttons = MessageBoxButtons.AbortRetryIg nore; DialogResult result = MessageBox.Show(message, title, buttons, MessageBoxIcon.Warning); if (result == DialogResult.Abort) { this.Close(); } elseif(result == DialogResult.Retry) { // Do nothing } else { // Do something }
  • 24. OUTUT
  • 25. Handling Events • Events are user actions such as key press, clicks, mouse movements, etc., or some occurrence such as system generated notifications. • Applications need to respond to events when they occur. For example, interrupts. Events are used for inter- process communication.
  • 26. Handling Events • An event can be declared in two steps: – Declare a delegate. – Declare a variable of the delegate with event keyword public delegate void Notify(); // delegate public class ProcessBusinessLogic { public event Notify ProcessCompleted; // event }
  • 27. Label • A Label control is used as a display medium for text on Forms. Label control does not participate in user input or capture mouse or keyboard events. • There are two ways to create a control.
  • 28. Label Design-Time • Step 1: Create a windows form as shown in the below image: Visual Studio -> File -> New -> Project -> WindowsFormApp • Step 2: Drag the Label control from the ToolBox and drop it on the windows form. You are allowed to place a Label control anywhere on the windows form according to your need. • Step 3: After drag and drop you will go to the properties of the Label control to set the properties of the Label according to your need.
  • 29. Label • 2. Run-Time: It is a little bit trickier than the above method. In this method, you can set create your own Label control using the Label class. Steps to create a dynamic label: • Step 1: Create a label using the Label() constructor is provided by the Label class. Label mylab = new Label(); • Step 2: After creating Label, set the properties of the Label provided by the Label class. mylab.Text = "GeeksforGeeks"; • Step 3: And last add this Label control to form using Add() method. this.Controls.Add(mylab);
  • 30. Label namespace WindowsFormsApp18 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // Creating and setting the label Label mylab = new Label(); mylab.Text = "GeeksforGeeks"; mylab.Location = new Point(222, 90); mylab.AutoSize = true; mylab.Font = new Font("Calibri", 18); mylab.ForeColor = Color.Green; mylab.Padding = new Padding(6); // Adding this control to the form this.Controls.Add(mylab); } } }
  • 31. TextBox • A TextBox control is used to display, or accept as input, a single line of text. • This control has additional functionality that is not found in the standard Windows text box control, including multiline editing and password character masking. • A text box object is used to display text on a form or to get user input while a C# program is running. In a text box, a user can type data or paste it into the control from the clipboard.
  • 32. TextBox string var; var = textBox1.Text;
  • 33. TextBox • Step 1 : Create a textbox using the TextBox() constructor provided by the TextBox class. TextBox Mytextbox = new TextBox(); • Step 2 : After creating TextBox, set the properties of the TextBox provided by the TextBox class. Mytextbox.Location = new Point(187, 51); • Step 3 : And last add this textbox control to from using Add() method. this.Controls.Add(Mytextbox);
  • 34. TextBoxusing System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace my { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Label Mylablel = new Label(); Mylablel.Location = new Point(96, 54); Mylablel.Text = "Enter Name"; Mylablel.AutoSize = true; Mylablel.BackColor = Color.LightGray; this.Controls.Add(Mylablel); TextBox Mytextbox = new TextBox(); Mytextbox.Location = new Point(187, 51); Mytextbox.BackColor = Color.LightGray; Mytextbox.ForeColor = Color.DarkOliveGreen; Mytextbox.AutoSize = true; Mytextbox.Name = "text_box1"; // Add this textbox to form this.Controls.Add(Mytextbox); } }}
  • 36. Button • A button is a control, which is an interactive component that enables users to communicate with an application. • The Button class inherits directly from the ButtonBase class. • A Button can be clicked by using the mouse, ENTER key, or SPACEBAR if the button has focus.
  • 37. Button • button1.Text = "Click Here"; • button1.Image = Image.FromFile("C:testimage.jpg");
  • 38. Button using System; using System.Windows.Forms; namespace WindowsFormsApplication21 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show("Dot Net Perls says hello.", "How is your day going?"); } } }
  • 39. Button • There are several events which we can use with buttons. • Events are some conditional checks to perform the specific functionalities when user will do something specific. • C# programming language provides a couple of events which you can use with button and we are going to implement some of them which are commonly used.. • Click Event • Text Changed Event • MouseHover Event • MouseLeave Event
  • 40. Combo Box • A ComboBox displays a text box combined with a ListBox, which enables the user to select items from the list or enter a new value.
  • 41. Combo Box • The user can type a value in the text field or click the button to display a drop down list. • User can add individual objects with the Add method. • user can delete items with the Remove method or clear the entire list with the Clear method.
  • 42. Combo Box add a item to combobox comboBox1.Items.Add("Sunday"); comboBox1.Items.Add("Monday"); comboBox1.Items.Add("Tuesday"); retrieve value from ComboBox string var; var = comboBox1.Text; Or var item = this.comboBox1.GetItemText(this.comboBox1.SelectedItem); MessageBox.Show(item);
  • 43. using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { comboBox1.Items.Add("weekdays"); comboBox1.Items.Add("year"); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox2.Items.Clear(); if (comboBox1.SelectedItem == "weekdays") { comboBox2.Items.Add("Sunday"); comboBox2.Items.Add("Monday"); comboBox2.Items.Add("Tuesday"); } else if (comboBox1.SelectedItem == "year") { comboBox2.Items.Add("2012"); comboBox2.Items.Add("2013"); comboBox2.Items.Add("2014"); } } }}
  • 45. List Box • The ListBox control enables you to display a list of items to the user that the user can select by clicking.
  • 46. List Box Setting ListBox Properties • set ListBox properties by using Properties Window. In order to get Properties window you can Press F4 or by right-clicking on a control to get the "Properties" menu item.
  • 47. List Box listBox1.Items.Add("Sunday"); listBox1.Items.Insert(0, "First"); listBox1.Items.Insert(1, "Second"); listBox1.Items.Insert(2, "Third"); listBox1.Items.Insert(3, "Forth"); string item = listBox1.GetItemText(listBox1.SelectedItem);
  • 48. using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { listBox1.Items.Add("Sunday"); listBox1.Items.Add("Monday"); listBox1.Items.Add("Tuesday"); listBox1.Items.Add("Wednesday"); listBox1.Items.Add("Thursday"); listBox1.Items.Add("Friday"); listBox1.Items.Add("Saturday"); listBox1.SelectionMode = SelectionMode.MultiSimple; } private void button1_Click(object sender, EventArgs e) { foreach (Object obj in listBox1.SelectedItems ) { MessageBox.Show(obj.ToString ()); }}}}
  • 49. Check Box • CheckBoxes allow the user to make multiple selections from a number of options. • CheckBox to give the user an option, such as true/false or yes/no. You can click a check box to select it and click it again to deselect it. • The CheckBox control can display an image or text or both. Usually CheckBox comes with a caption, which you can set in the Text property.
  • 50. Check Box • CheckBox control ThreeState property to direct the control to return the Checked, Unchecked, and Indeterminate values. User • need to set the check boxs ThreeState property to True to indicate that you want it to support three states. checkBox1.ThreeState = true;
  • 51. using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string msg = ""; if (checkBox1.Checked == true) { msg = "net-informations.com"; } if (checkBox2.Checked == true) { msg = msg + " vb.net-informations.com"; } if (checkBox3.Checked == true) { msg = msg + " csharp.net-informations.com"; } if (msg.Length > 0) { MessageBox.Show (msg + " selected "); } else { MessageBox.Show ("No checkbox selected"); } checkBox1.ThreeState = true; } } }
  • 52. Radio Button • A radio button or option button enables the user to select a single option from a group of choices when paired with other RadioButton controls. • When a user clicks on a radio button, it becomes checked, and all other radio buttons with same group become unchecked.
  • 53. Radio Button • The RadioButton control can display text, an Image, or both. Use the Checked property to get or set the state of a RadioButton. radioButton1.Checked = true; • The radio button and the check box are used for different functions. • Use a radio button when you want the user to choose only one option. • When you want the user to choose all appropriate options, use a check box. • Like check boxes, radio buttons support a Checked property that indicates whether the radio button is selected.
  • 54. using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { radioButton1.Checked = true; } private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked == true) { MessageBox.Show ("You are selected Red !! "); return; } else if (radioButton2.Checked == true) { MessageBox.Show("You are selected Blue !! "); return; } else { MessageBox.Show("You are selected Green !! "); return; } } } }
  • 55. Group Box • A GroupBox control is a container control used to group similar controls. • A GroupBox control is a container control that is used to place Windows Forms child controls in a group. • The purpose of a GroupBox is to define user interfaces where we can categorize related controls in a group.
  • 56. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApp45 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // Creating and setting // properties of the GroupBox GroupBox box = new GroupBox(); box.Location = new Point(179, 145); box.Size = new Size(329, 94); box.Text = "Select Gender"; box.Name = "MyGroupbox"; // Adding groupbox in the form this.Controls.Add(box); // Creating and setting // properties of the CheckBox CheckBox b1 = new CheckBox(); b1.Location = new Point(40, 42); b1.Size = new Size(49, 20); b1.Text = "Male"; // Adding this control // to the GroupBox gbox.Controls.Add(b1); // Creating and setting // properties of the CheckBox CheckBox b2 = new CheckBox(); b2.Location = new Point(183, 39); b2.Size = new Size(69, 20); b2.Text = "Female"; // Adding this control // to the GroupBox box.Controls.Add(b2); } } }
  • 58. Picture Box • The Windows Forms PictureBox control is used to display images in bitmap, GIF , icon , or JPEG formats. • User can set the Image property to the Image you want to display, either at design time or at run time. • User can programmatically change the image displayed in a picture box, which is particularly useful when you use a single form to display different pieces of information.
  • 60. Picture Box using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { pictureBox1.Image = Image.FromFile("c:testImage.jpg"); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; } } }
  • 61. Timer • C# Timer is used to implement a timer in C#. • For example, backing up a folder every 10 minutes, or writing to a log file every second. The method that needs to be executed is placed inside the event of the timer. • With the Timer Control we can raise events at a specific interval of time without the interaction of another thread.
  • 62. Timer • Set the Interval property to 1000. The value of Interval property is in milliseconds. • 1 sec = 1000 milliseconds. • By default the Enabled property of Timer Control is False. • So before running the program we have to set the Enabled property is True , then only the Timer Control starts its function.
  • 63. Timer • User have to use Timer Object when user want to set an interval between events, periodic checking, to start a process at a fixed time schedule, to increase or decrease the speed in an animation graphics with time schedule etc. • A Timer control does not have a visual representation and works as a component in the background.
  • 64. Timer using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void timer1_Tick(object sender, EventArgs e) { label1.Text = DateTime.Now.ToString(); } } }
  • 65. Open File Dialog • The OpenFileDialog component allows users to browse the folders of their computer or any computer on the network and select one or more files to open. • The dialog box returns the path and name of the file the user selected in the dialog box.
  • 66. Open File Dialog • The FileName property can be set prior to showing the dialog box. This causes the dialog box to initially display the given filename. • In most cases, your applications should set the InitialDirectory, Filter, and FilterIndex properties prior to calling ShowDialog.
  • 67. Open File Dialog namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.ShowDialog(); if (dlg.ShowDialog() == DialogResult.OK) { string fileName; fileName = dlg.FileName; MessageBox.Show(fileName); } } } }
  • 68. Save File Dialog • SaveFileDialog control is used to save a file using Windows SaveFileDialog.
  • 69. Save File Dialog SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Title = "Save"; saveDialog.Filter = "Text Files (*.txt)|*.txt" + "|" + "Image Files (*.png;*.jpg)|*.png;*.jpg" + "|" + "All Files (*.*)|*.*"; if (saveDialog.ShowDialog() == DialogResult.OK) { string file = saveDialog.FileName; }
  • 70. Font Dialog • Font dialog box represents a common dialog box that displays a list of fonts that are currently installed on the system. • The Font dialog box lets the user choose attributes for a logical font, such as font family and associated font style, point size, effects , and a script .
  • 71. using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { FontDialog dlg = new FontDialog(); dlg.ShowDialog(); if (dlg.ShowDialog() == DialogResult.OK) { string fontName; float fontSize; fontName = dlg.Font.Name; fontSize = dlg.Font.Size; MessageBox.Show(fontName + " " + fontSize ); } } } }
  • 72. Color Dialog • A C# ColorDialog control is used to select a color from available colors and also define custom colors.
  • 73. Color Dialog using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { ColorDialog dlg = new ColorDialog(); dlg.ShowDialog(); if (dlg.ShowDialog() == DialogResult.OK) { string str = null; str = dlg.Color.Name; MessageBox.Show (str); } } } }
  • 74. Print Dialog • A user can use the Print dialog box to select a printer, configure it, and perform a print job. • Print dialog boxes provide an easy way to implement Print and Print Setup dialog boxes in a manner consistent with Windows standards. • The Print dialog box includes a Print Range group of radio buttons that indicate whether the user wants to print all pages , a range of pages, or only the selected text. • The dialog box includes an edit control in which the user can type the number of copies to print . • By default, the Print dialog box initially displays information about the current default printer.
  • 75. Print Dialog using System; using System.Drawing; using System.Windows.Forms; namespace Win dowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { PrintDialog dlg = new PrintDialog(); dlg.ShowDialog(); } } }
  • 76. Tree View • The TreeView control contains a hierarchy of TreeViewItem controls. • It provides a way to display information in a hierarchical structure by using collapsible nodes . • The top level in a tree view are root nodes that can be expanded or collapsed if the nodes have child nodes. • The user can expand the TreeNode by clicking the plus sign (+) button, if one is displayed next to the TreeNode, or you can expand the TreeNode by calling the TreeNode.Expand method. • You can also navigate through tree views with various properties: FirstNode, LastNode, NextNode, PrevNode, NextVisibleNode, PrevVisibleNode.
  • 77. using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { TreeNode tNode ; tNode = treeView1.Nodes.Add("Websites"); treeView1.Nodes[0].Nodes.Add("Net-informations.com"); treeView1.Nodes[0].Nodes[0].Nodes.Add("CLR"); treeView1.Nodes[0].Nodes.Add("Vb.net-informations.com"); treeView1.Nodes[0].Nodes[1].Nodes.Add("String Tutorial"); treeView1.Nodes[0].Nodes[1].Nodes.Add("Excel Tutorial"); treeView1.Nodes[0].Nodes.Add("Csharp.net-informations.com"); treeView1.Nodes[0].Nodes[2].Nodes.Add("ADO.NET"); treeView1.Nodes[0].Nodes[2].Nodes[0].Nodes.Add("Dataset"); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show(treeView1.SelectedNode.FullPath.ToString ()); } } }
  • 79. Menu • MainMenu is the container for the Menu structure of the form and menus are made of MenuItem objects that represent individual parts of a menu.
  • 80. Menu • After drag the Menustrip on your form you can directly create the menu items by type a value into the "Type Here" box on the menubar part of your form.
  • 81. Menu • If you need a seperator bar , right click on your menu then go to insert- >Seperator. • After creating the Menu on the form , you have to double click on each menu item and write the programs there depends on your requirements.
  • 82. Menu using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void menu1ToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("You are selected MenuItem_1"); } } }