SlideShare a Scribd company logo
1 of 13
Download to read offline
Visual C# .Net using
framework 4.5
Eng. Mahmoud Ouf
Lecture 08
mmouf@2018
Menu
In windows applications, menus are used to provide a list of commands
available for user to execute in the application. Example the File menu,
which contain New, Open, Close, …
The menu that sits between a form’s title bar and the client area is referred as
main menu.
Many application support Shortcut menus, context menus, which are menus
that appear at the mouse cursor position when you right click the mouse.
A main menu is associated with a form, while context menu is associated
with a particular control, that is clicking different controls often causes
different context menus to be invoked.
A menu (main or context) contains menu items, such as File, Open, Save,..
mmouf@2018
Menu
You will find that the File and Edit menu items are different from the Open,
Save items. File, Edit are located at the visible part of the program main
menu, while other are not.
The items at the visible part are called “Top Level Item”. Selecting any Top
Level Item will invoke a menu was called “PopUp menu” or “Drop Down
Menu” but now is called SubMenu or ChildMenu.
From the Windows Forms program, The File menu item contains a
collection of other menu items contains (Open, Save,…) and the Edit menu
item contains a collection of menu items contains (Cut, Copy,…).
One step back, the Main menu itself is a collection of menu items contains
(File, Edit,…). Each menu item in the Main menu is associated with its own
array of menu items. And in some case some of these menu items have their
own array of menu items.
mmouf@2018
Menu
Similarly, a context menu is an array of menu items.
To Deal With menus, we have 3 classes:
MenuStrip (the main menu)
ToolStripMenuItem (sub menus)
ContextMenuStrip (context menu)
mmouf@2018
Menu
Creating the Main Menu
1) Create an object from the MenuStrip class
2) Create the Top Level Menu item (object from ToolStripMenuItem
class)
3) Add this object (from ToolStripMenuItem) to the object (from
MenuStrip) use “items collection”
4) Now, make the submenu item (Object from ToolStripMenuItem)
5) Add it to the Top Level Menu (use DropDownItems collections)
6) Repeat steps 4, 5 to add other submenu
7) Repeat Steps 2 to 6 to add other top level Menu items
8) Attach MainMenu to the Form
mmouf@2018
Menu
Creating the Main Menu
Step 1:
MenuStrip menuStrip1; //define the object
menuStrip1 = new MenuStrip(); //object creation
Step 2:
ToolStripMenuItem fileToolStripMenuItem =
new ToolStripMenuItem(“&File”);
Step 3:
menuStrip1.Items.Add(this.fileToolStripMenuItem);
mmouf@2018
Menu
Creating the Main Menu
Step 4:
ToolStripMenuItem exitToolStripMenuItem =
new ToolStripMenuItem (“E&xit”,
new EventHandler(this.exitToolStripMenuItem_Click));
exitToolStripMenuItem.ShortcutKeys = (Keys)(Keys.Control | Keys.X);
Step 5:
fileToolStripMenuItem.DropDownItems.Add(this.exitToolStripMenuItem);
Step 8:
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
mmouf@2018
Menu
Creating the Main Menu
Step 4:
ToolStripMenuItem exitToolStripMenuItem =
new ToolStripMenuItem (“E&xit”,
new EventHandler(this.exitToolStripMenuItem_Click));
exitToolStripMenuItem.ShortcutKeys = (Keys)(Keys.Control | Keys.X);
Step 5:
fileToolStripMenuItem.DropDownItems.Add(this.exitToolStripMenuItem);
Step 8:
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
mmouf@2018
Menu
Creating the Main Menu
The & in the menu name string, tell which variable will be associated with
the Alt key to open the menu
Also, each command may have a shortcut to execute this command with no
need to open the menu
mmouf@2018
Context Menu
Creating the Context Menu
1) Create an object from the ContextMenuStrip class
2) Now, make the submenu item (object from ToolStripMenuItem)
3) Add it to the ContextMenuStrip (using Items collections)
4) Repeat steps 2, 3 to add other submenu
5) Attach ContextMenuStrip to the Form (through contextMenuStrip
property of the form)
mmouf@2018
Toolbar
Toolbars provides an alternate means to activate a given menu item. Most
applications use toolbar images that are 16 pixels square.
This is done by ToolStrip class
It can Contains:
ToolStripButton,
ToolStripLabel,
ToolStripDropDownButton,
ToolStripComboBox,
ToolStripTextBox
mmouf@2018
Toolbar
Creating and using Toolbar
1) Create object From ToolStrip class
2) Create objects From ToolStripButton, ToolStripLabel, … class
3) Configure each object
4) Configure toolbar and Add buttons (using Items collection)
5) Add the new bar to the control (using Controls collection)
mmouf@2018
Status bar
Status bars usually conveys textual information to the user.
This is done by StatusStrip class
It can Contains:
ToolStripStatusLabel,
ToolStripDropDownButton,
ToolStripProgressBar
Creating and using Status bar
1) Create object From StatusStrip class
2) Create objects From ToolStripStatusLabel,
ToolStripDropDownButton, … class
3) Configure each object
4) Configure status bar and Add buttons (using Items collection)
5) Add the new bar to the control (using Controls collection)
mmouf@2018

More Related Content

What's hot

C# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slidesC# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slidesSami Mut
 
Chapter 2 — Program and Graphical User Interface Design
Chapter 2 — Program and Graphical User Interface DesignChapter 2 — Program and Graphical User Interface Design
Chapter 2 — Program and Graphical User Interface Designfrancopw
 
Windows form application - C# Training
Windows form application - C# Training Windows form application - C# Training
Windows form application - C# Training Moutasm Tamimi
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinFormHock Leng PUAH
 
Windows Forms For Beginners Part - 4
Windows Forms For Beginners Part - 4Windows Forms For Beginners Part - 4
Windows Forms For Beginners Part - 4Bhushan Mulmule
 
Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1Bhushan Mulmule
 
06 win forms
06 win forms06 win forms
06 win formsmrjw
 
Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Bhushan Mulmule
 
Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Bhushan Mulmule
 
Class viii ch-7 visual basic 2008
Class  viii ch-7 visual basic 2008Class  viii ch-7 visual basic 2008
Class viii ch-7 visual basic 2008jessandy
 
Chapter 07
Chapter 07Chapter 07
Chapter 07llmeade
 
Visual Basic Programming
Visual Basic ProgrammingVisual Basic Programming
Visual Basic ProgrammingOsama Yaseen
 
Session 1. Bai 1 ve winform
Session 1. Bai 1 ve winformSession 1. Bai 1 ve winform
Session 1. Bai 1 ve winformmrtom16071980
 
Mat. pemvis pertemuan iv
Mat. pemvis pertemuan ivMat. pemvis pertemuan iv
Mat. pemvis pertemuan ivHusna Rusdiani
 

What's hot (20)

C# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slidesC# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slides
 
Chapter 2 — Program and Graphical User Interface Design
Chapter 2 — Program and Graphical User Interface DesignChapter 2 — Program and Graphical User Interface Design
Chapter 2 — Program and Graphical User Interface Design
 
SPF WinForm Programs
SPF WinForm ProgramsSPF WinForm Programs
SPF WinForm Programs
 
Windows form application - C# Training
Windows form application - C# Training Windows form application - C# Training
Windows form application - C# Training
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinForm
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 
Windows Forms For Beginners Part - 4
Windows Forms For Beginners Part - 4Windows Forms For Beginners Part - 4
Windows Forms For Beginners Part - 4
 
Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1
 
06 win forms
06 win forms06 win forms
06 win forms
 
visual basic programming
visual basic programmingvisual basic programming
visual basic programming
 
Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3
 
Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5
 
Controls events
Controls eventsControls events
Controls events
 
Active x control
Active x controlActive x control
Active x control
 
Class viii ch-7 visual basic 2008
Class  viii ch-7 visual basic 2008Class  viii ch-7 visual basic 2008
Class viii ch-7 visual basic 2008
 
Chapter 07
Chapter 07Chapter 07
Chapter 07
 
Vb basics
Vb basicsVb basics
Vb basics
 
Visual Basic Programming
Visual Basic ProgrammingVisual Basic Programming
Visual Basic Programming
 
Session 1. Bai 1 ve winform
Session 1. Bai 1 ve winformSession 1. Bai 1 ve winform
Session 1. Bai 1 ve winform
 
Mat. pemvis pertemuan iv
Mat. pemvis pertemuan ivMat. pemvis pertemuan iv
Mat. pemvis pertemuan iv
 

Similar to Intake 38 8

1 PROBLEM You are to design and implement a Menu class.docx
1 PROBLEM You are to design and implement a Menu class.docx1 PROBLEM You are to design and implement a Menu class.docx
1 PROBLEM You are to design and implement a Menu class.docxhoney725342
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI WidgetsAhsanul Karim
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Ahsanul Karim
 
Components of windows.36
Components of windows.36Components of windows.36
Components of windows.36myrajendra
 
360 Flex Atlanta
360 Flex Atlanta360 Flex Atlanta
360 Flex Atlantartretola
 
How do i add a file menu to my java programSolutionHere goes .pdf
How do i add a file menu to my java programSolutionHere goes .pdfHow do i add a file menu to my java programSolutionHere goes .pdf
How do i add a file menu to my java programSolutionHere goes .pdffathimaoptical
 
Menu bars and menus
Menu bars and menusMenu bars and menus
Menu bars and menusmyrajendra
 
INTRODUCTION The goal of this programming project is to entble studen.pdf
 INTRODUCTION The goal of this programming project is to entble studen.pdf INTRODUCTION The goal of this programming project is to entble studen.pdf
INTRODUCTION The goal of this programming project is to entble studen.pdfameancal
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAhsanul Karim
 
Autodesk maya 2016 basic guide
Autodesk maya 2016 basic guideAutodesk maya 2016 basic guide
Autodesk maya 2016 basic guideĐỗ Hải
 

Similar to Intake 38 8 (20)

Intake 37 8
Intake 37 8Intake 37 8
Intake 37 8
 
Android ui menu
Android ui menuAndroid ui menu
Android ui menu
 
android menus
android menusandroid menus
android menus
 
1 PROBLEM You are to design and implement a Menu class.docx
1 PROBLEM You are to design and implement a Menu class.docx1 PROBLEM You are to design and implement a Menu class.docx
1 PROBLEM You are to design and implement a Menu class.docx
 
Android session 3
Android session 3Android session 3
Android session 3
 
Vs c# lecture5
Vs c# lecture5Vs c# lecture5
Vs c# lecture5
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
 
Swing jecrc
Swing jecrc Swing jecrc
Swing jecrc
 
Gui
GuiGui
Gui
 
Components of windows.36
Components of windows.36Components of windows.36
Components of windows.36
 
360 Flex Atlanta
360 Flex Atlanta360 Flex Atlanta
360 Flex Atlanta
 
Module iii part i
Module iii part iModule iii part i
Module iii part i
 
01 10 - graphical user interface - others
01  10 - graphical user interface - others01  10 - graphical user interface - others
01 10 - graphical user interface - others
 
How do i add a file menu to my java programSolutionHere goes .pdf
How do i add a file menu to my java programSolutionHere goes .pdfHow do i add a file menu to my java programSolutionHere goes .pdf
How do i add a file menu to my java programSolutionHere goes .pdf
 
Menu bars and menus
Menu bars and menusMenu bars and menus
Menu bars and menus
 
INTRODUCTION The goal of this programming project is to entble studen.pdf
 INTRODUCTION The goal of this programming project is to entble studen.pdf INTRODUCTION The goal of this programming project is to entble studen.pdf
INTRODUCTION The goal of this programming project is to entble studen.pdf
 
Android menus in android-chapter15
Android menus in android-chapter15Android menus in android-chapter15
Android menus in android-chapter15
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form Widgets
 
Autodesk maya 2016 basic guide
Autodesk maya 2016 basic guideAutodesk maya 2016 basic guide
Autodesk maya 2016 basic guide
 

More from Mahmoud Ouf

More from Mahmoud Ouf (20)

Relation between classes in arabic
Relation between classes in arabicRelation between classes in arabic
Relation between classes in arabic
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5
 
Intake 38 data access 4
Intake 38 data access 4Intake 38 data access 4
Intake 38 data access 4
 
Intake 38 data access 3
Intake 38 data access 3Intake 38 data access 3
Intake 38 data access 3
 
Intake 38 data access 1
Intake 38 data access 1Intake 38 data access 1
Intake 38 data access 1
 
Intake 38 12
Intake 38 12Intake 38 12
Intake 38 12
 
Intake 38 11
Intake 38 11Intake 38 11
Intake 38 11
 
Intake 38 10
Intake 38 10Intake 38 10
Intake 38 10
 
Intake 38 9
Intake 38 9Intake 38 9
Intake 38 9
 
Intake 38 7
Intake 38 7Intake 38 7
Intake 38 7
 
Intake 38 6
Intake 38 6Intake 38 6
Intake 38 6
 
Intake 38 5 1
Intake 38 5 1Intake 38 5 1
Intake 38 5 1
 
Intake 38 5
Intake 38 5Intake 38 5
Intake 38 5
 
Intake 38 4
Intake 38 4Intake 38 4
Intake 38 4
 
Intake 38 3
Intake 38 3Intake 38 3
Intake 38 3
 
Intake 38 2
Intake 38 2Intake 38 2
Intake 38 2
 
Intake 38_1
Intake 38_1Intake 38_1
Intake 38_1
 
Intake 37 DM
Intake 37 DMIntake 37 DM
Intake 37 DM
 
Intake 37 ef2
Intake 37 ef2Intake 37 ef2
Intake 37 ef2
 
Intake 37 ef1
Intake 37 ef1Intake 37 ef1
Intake 37 ef1
 

Recently uploaded

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
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
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
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
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
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

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
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
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
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.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
 
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
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

Intake 38 8

  • 1. Visual C# .Net using framework 4.5 Eng. Mahmoud Ouf Lecture 08 mmouf@2018
  • 2. Menu In windows applications, menus are used to provide a list of commands available for user to execute in the application. Example the File menu, which contain New, Open, Close, … The menu that sits between a form’s title bar and the client area is referred as main menu. Many application support Shortcut menus, context menus, which are menus that appear at the mouse cursor position when you right click the mouse. A main menu is associated with a form, while context menu is associated with a particular control, that is clicking different controls often causes different context menus to be invoked. A menu (main or context) contains menu items, such as File, Open, Save,.. mmouf@2018
  • 3. Menu You will find that the File and Edit menu items are different from the Open, Save items. File, Edit are located at the visible part of the program main menu, while other are not. The items at the visible part are called “Top Level Item”. Selecting any Top Level Item will invoke a menu was called “PopUp menu” or “Drop Down Menu” but now is called SubMenu or ChildMenu. From the Windows Forms program, The File menu item contains a collection of other menu items contains (Open, Save,…) and the Edit menu item contains a collection of menu items contains (Cut, Copy,…). One step back, the Main menu itself is a collection of menu items contains (File, Edit,…). Each menu item in the Main menu is associated with its own array of menu items. And in some case some of these menu items have their own array of menu items. mmouf@2018
  • 4. Menu Similarly, a context menu is an array of menu items. To Deal With menus, we have 3 classes: MenuStrip (the main menu) ToolStripMenuItem (sub menus) ContextMenuStrip (context menu) mmouf@2018
  • 5. Menu Creating the Main Menu 1) Create an object from the MenuStrip class 2) Create the Top Level Menu item (object from ToolStripMenuItem class) 3) Add this object (from ToolStripMenuItem) to the object (from MenuStrip) use “items collection” 4) Now, make the submenu item (Object from ToolStripMenuItem) 5) Add it to the Top Level Menu (use DropDownItems collections) 6) Repeat steps 4, 5 to add other submenu 7) Repeat Steps 2 to 6 to add other top level Menu items 8) Attach MainMenu to the Form mmouf@2018
  • 6. Menu Creating the Main Menu Step 1: MenuStrip menuStrip1; //define the object menuStrip1 = new MenuStrip(); //object creation Step 2: ToolStripMenuItem fileToolStripMenuItem = new ToolStripMenuItem(“&File”); Step 3: menuStrip1.Items.Add(this.fileToolStripMenuItem); mmouf@2018
  • 7. Menu Creating the Main Menu Step 4: ToolStripMenuItem exitToolStripMenuItem = new ToolStripMenuItem (“E&xit”, new EventHandler(this.exitToolStripMenuItem_Click)); exitToolStripMenuItem.ShortcutKeys = (Keys)(Keys.Control | Keys.X); Step 5: fileToolStripMenuItem.DropDownItems.Add(this.exitToolStripMenuItem); Step 8: this.Controls.Add(this.menuStrip1); this.MainMenuStrip = this.menuStrip1; mmouf@2018
  • 8. Menu Creating the Main Menu Step 4: ToolStripMenuItem exitToolStripMenuItem = new ToolStripMenuItem (“E&xit”, new EventHandler(this.exitToolStripMenuItem_Click)); exitToolStripMenuItem.ShortcutKeys = (Keys)(Keys.Control | Keys.X); Step 5: fileToolStripMenuItem.DropDownItems.Add(this.exitToolStripMenuItem); Step 8: this.Controls.Add(this.menuStrip1); this.MainMenuStrip = this.menuStrip1; mmouf@2018
  • 9. Menu Creating the Main Menu The & in the menu name string, tell which variable will be associated with the Alt key to open the menu Also, each command may have a shortcut to execute this command with no need to open the menu mmouf@2018
  • 10. Context Menu Creating the Context Menu 1) Create an object from the ContextMenuStrip class 2) Now, make the submenu item (object from ToolStripMenuItem) 3) Add it to the ContextMenuStrip (using Items collections) 4) Repeat steps 2, 3 to add other submenu 5) Attach ContextMenuStrip to the Form (through contextMenuStrip property of the form) mmouf@2018
  • 11. Toolbar Toolbars provides an alternate means to activate a given menu item. Most applications use toolbar images that are 16 pixels square. This is done by ToolStrip class It can Contains: ToolStripButton, ToolStripLabel, ToolStripDropDownButton, ToolStripComboBox, ToolStripTextBox mmouf@2018
  • 12. Toolbar Creating and using Toolbar 1) Create object From ToolStrip class 2) Create objects From ToolStripButton, ToolStripLabel, … class 3) Configure each object 4) Configure toolbar and Add buttons (using Items collection) 5) Add the new bar to the control (using Controls collection) mmouf@2018
  • 13. Status bar Status bars usually conveys textual information to the user. This is done by StatusStrip class It can Contains: ToolStripStatusLabel, ToolStripDropDownButton, ToolStripProgressBar Creating and using Status bar 1) Create object From StatusStrip class 2) Create objects From ToolStripStatusLabel, ToolStripDropDownButton, … class 3) Configure each object 4) Configure status bar and Add buttons (using Items collection) 5) Add the new bar to the control (using Controls collection) mmouf@2018