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@2017
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@2017
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@2017
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@2017
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@2017
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@2017
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@2017
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@2017
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@2017
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@2017
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@2017
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@2017
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@2017

More Related Content

Viewers also liked

The Monster of Hate
The Monster of HateThe Monster of Hate
The Monster of HateOH TEIK BIN
 
[Winform] Visual studio C# 2012 Setting themes with telerik themes library
[Winform] Visual studio C# 2012 Setting themes with telerik themes library[Winform] Visual studio C# 2012 Setting themes with telerik themes library
[Winform] Visual studio C# 2012 Setting themes with telerik themes libraryJunifar hidayat
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinFormHock Leng PUAH
 
¿Qué es red remedia?
¿Qué es red remedia?¿Qué es red remedia?
¿Qué es red remedia?REMEDIAnetwork
 
Pdfc fast food-mastercode.vn
Pdfc fast food-mastercode.vnPdfc fast food-mastercode.vn
Pdfc fast food-mastercode.vnMasterCode.vn
 
Publikasi Indikator Mutu Rumah Sakit Cakra Husada Klaten
Publikasi Indikator Mutu Rumah Sakit Cakra Husada KlatenPublikasi Indikator Mutu Rumah Sakit Cakra Husada Klaten
Publikasi Indikator Mutu Rumah Sakit Cakra Husada KlatenMade Sumiarta
 

Viewers also liked (13)

Intake 37 2
Intake 37 2Intake 37 2
Intake 37 2
 
The Monster of Hate
The Monster of HateThe Monster of Hate
The Monster of Hate
 
Intake 37 1
Intake 37 1Intake 37 1
Intake 37 1
 
Intake 37 linq3
Intake 37 linq3Intake 37 linq3
Intake 37 linq3
 
[Winform] Visual studio C# 2012 Setting themes with telerik themes library
[Winform] Visual studio C# 2012 Setting themes with telerik themes library[Winform] Visual studio C# 2012 Setting themes with telerik themes library
[Winform] Visual studio C# 2012 Setting themes with telerik themes library
 
Intake 37 5
Intake 37 5Intake 37 5
Intake 37 5
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinForm
 
¿Qué es red remedia?
¿Qué es red remedia?¿Qué es red remedia?
¿Qué es red remedia?
 
Pdfc fast food-mastercode.vn
Pdfc fast food-mastercode.vnPdfc fast food-mastercode.vn
Pdfc fast food-mastercode.vn
 
Intake 37 ef1
Intake 37 ef1Intake 37 ef1
Intake 37 ef1
 
Publikasi Indikator Mutu Rumah Sakit Cakra Husada Klaten
Publikasi Indikator Mutu Rumah Sakit Cakra Husada KlatenPublikasi Indikator Mutu Rumah Sakit Cakra Husada Klaten
Publikasi Indikator Mutu Rumah Sakit Cakra Husada Klaten
 
Deutsche Angst
Deutsche AngstDeutsche Angst
Deutsche Angst
 
Intake 37 ef2
Intake 37 ef2Intake 37 ef2
Intake 37 ef2
 

Similar to Intake 37 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
 
Windows xp stack
Windows xp stackWindows xp stack
Windows xp stackLisa Stack
 
VB6_OBJECTS AND GRAPHICS.ppt
VB6_OBJECTS AND GRAPHICS.pptVB6_OBJECTS AND GRAPHICS.ppt
VB6_OBJECTS AND GRAPHICS.pptBhuvanaR13
 
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
 
Lecture windows xp 3
Lecture windows xp 3Lecture windows xp 3
Lecture windows xp 3Shafaq Saleem
 
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
 

Similar to Intake 37 8 (20)

Intake 38 8
Intake 38 8Intake 38 8
Intake 38 8
 
android menus
android menusandroid menus
android menus
 
Android ui menu
Android ui menuAndroid ui menu
Android ui menu
 
Vs c# lecture5
Vs c# lecture5Vs c# lecture5
Vs c# lecture5
 
Android session 3
Android session 3Android session 3
Android session 3
 
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
 
Gui
GuiGui
Gui
 
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]
 
01 10 - graphical user interface - others
01  10 - graphical user interface - others01  10 - graphical user interface - others
01 10 - graphical user interface - others
 
Swing jecrc
Swing jecrc Swing jecrc
Swing jecrc
 
Windows xp stack
Windows xp stackWindows xp stack
Windows xp stack
 
Windows xp
Windows xpWindows xp
Windows xp
 
VB6_OBJECTS AND GRAPHICS.ppt
VB6_OBJECTS AND GRAPHICS.pptVB6_OBJECTS AND GRAPHICS.ppt
VB6_OBJECTS AND GRAPHICS.ppt
 
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
 
Vp lecture 11 ararat
Vp lecture 11 araratVp lecture 11 ararat
Vp lecture 11 ararat
 
Lecture windows xp 3
Lecture windows xp 3Lecture windows xp 3
Lecture windows xp 3
 
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 stripe
Menu stripeMenu stripe
Menu stripe
 

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 linq1
Intake 37 linq1Intake 37 linq1
Intake 37 linq1
 
Intake 37 12
Intake 37 12Intake 37 12
Intake 37 12
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Intake 37 8

  • 1. Visual C# .Net using framework 4.5 Eng. Mahmoud Ouf Lecture 08 mmouf@2017
  • 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@2017
  • 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@2017
  • 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@2017
  • 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@2017
  • 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@2017
  • 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@2017
  • 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@2017
  • 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@2017
  • 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@2017
  • 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@2017
  • 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@2017
  • 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@2017