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,PROGRAMMING,C#,C# CONCEPTS,SIMPLE CONCEPTS IN C#.
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.
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
}
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.
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.
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.
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");
} } }