{"id":10087,"date":"2023-07-04T08:33:58","date_gmt":"2023-07-04T05:03:58","guid":{"rendered":"http:\/\/milmit.net\/menustrip-training-in-c\/"},"modified":"2023-07-04T08:33:58","modified_gmt":"2023-07-04T05:03:58","slug":"menustrip-training-in-c","status":"publish","type":"post","link":"https:\/\/milmit.net\/en\/menustrip-training-in-c\/","title":{"rendered":"MenuStrip training in C#"},"content":{"rendered":"<p>C# (C#) programming training, we will teach MenuStrip in C# (C#) in order to create a menu (menu) in your C# project, you need to use MenuStrip. Stay with us to learn how to use and implement. Learn MenuStrip tutorial in C#.<\/p>\n<p>Like all C# objects, we can create MenuStrip or menu by using code and also by using drag and drop.<br \/>\nWell, in order to come through the ui, create a menu similar to the one below, just follow the pictures below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-62801\" src=\"http:\/\/www.programchi.ir\/\/wp-content\/uploads\/2018\/08\/form_done.gif\" alt=\"\" width=\"400\" height=\"358\" \/><\/p>\n<p>Drag and drop the MenuStrip onto the form.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-62802\" src=\"http:\/\/www.programchi.ir\/\/wp-content\/uploads\/2018\/08\/menu_add_step1.gif\" alt=\"\" width=\"300\" height=\"300\" \/>After that, you can create your own menus in the Type Here section, just type in it.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-62803\" src=\"http:\/\/www.programchi.ir\/\/wp-content\/uploads\/2018\/08\/menu_add_step2.gif\" alt=\"\" width=\"300\" height=\"92\" \/><\/p>\n<p>We implemented something like this.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-62804\" src=\"http:\/\/www.programchi.ir\/\/wp-content\/uploads\/2018\/08\/menu_add_step8.gif\" alt=\"\" width=\"391\" height=\"318\" \/>To create a click event, just double-click on each one and write the code in the opened event.<br \/>\nLet&#8217;s go to create a menu using code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">MenuStrip MainMenu = new MenuStrip();\r\nMainMenu.BackColor = Color.OrangeRed;\r\nMainMenu.ForeColor = Color.Black;\r\nMainMenu.Text = \"File Menu\";\r\nMainMenu.Font = new Font(\"Georgia\", 16);<\/pre>\n<p>Above, the MenuStrip object is created, then the background color and text are determined, as well as the font.<br \/>\nThe Text feature is used to determine the text of the menu.<br \/>\nUse the following code to determine whether Menu is left-aligned or right-aligned.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">MainMenu.Dock = DockStyle.Left;<\/pre>\n<p>To create Menu Items, you must use the following code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ToolStripMenuItem FileMenu = new ToolStripMenuItem(\"File\");\r\nFileMenu.BackColor = Color.OrangeRed;\r\nFileMenu.ForeColor = Color.Black;\r\nFileMenu.Text = \"File Menu\";\r\nFileMenu.Font = new Font(\"Georgia\", 16);\r\nFileMenu.TextAlign = ContentAlignment.BottomRight;\r\nFileMenu.ToolTipText = \"Click Me\";\r\nMainMenu.Items.Add(FileMenu);<\/pre>\n<p>Above, we have added an item to the first option, namely File, and some features have been used to determine the color of the text and background, as well as the font.<br \/>\nTo define the click event on the Menu, just use the following Event.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">FileMenu.Click += new System.EventHandler(this.FileMenuItemClick);\r\nprivate void FileMenuItemClick(object sender, EventArgs e)\r\n{\r\n    MessageBox.Show(\"File menu item clicked\");\r\n}<\/pre>\n<p>be successful and victorious.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C# (C#) programming training, we will teach MenuStrip in C# (C#) in order to create a menu (menu) in your C# project, you need to use MenuStrip. Stay with us to learn how to use and implement. Learn MenuStrip tutorial in C#. Like all C# objects, we can create MenuStrip or menu by using code [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":4929,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-10087","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/posts\/10087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/comments?post=10087"}],"version-history":[{"count":0,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/posts\/10087\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/media\/4929"}],"wp:attachment":[{"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/media?parent=10087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/categories?post=10087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/tags?post=10087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}