menustrip

“Red Cross” problem on MenuStrip and ToolStrip

試著忘記壹切 提交于 2019-12-19 08:53:55
问题 I have a piece of software that has worked fine on many machines, althoughon one machine there is a problem that appears to occur occasionaly, the MenuStrip and the ToolStrip both appear as a blank white background with a red cross over it, as a custom control would if you created a null object. This doesn't happen whilst I am debugging and I don't know how to make the problem re-occur, but it does happen. I was wondering if anyone knew what could be the problem? Would it be the version of

Disable ToolStripMenuItem highlight?

只愿长相守 提交于 2019-12-12 17:01:36
问题 I have an application with a MenuStrip and every time I hover my mouse over a MenuItem, it highlights blue. I have tried to change the BackColor and ForeColor but that wasn't the problem. Is there a way to disable this? 回答1: This would be incredibly un-useful to the end user: internal class NoHighlightRenderer : ToolStripProfessionalRenderer { protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) { if (e.Item.OwnerItem == null) { base.OnRenderMenuItemBackground(e)

Can a MenuStrip control have its LayoutStyle set to StackWithOverflow?

蹲街弑〆低调 提交于 2019-12-12 10:53:17
问题 I create a simple form with a MenuStrip. The MenuStrip's LayoutStyle is set to HorizontalStackWithOverflow (the default). According to the MSDN reference on MenuStrip, its LayoutStyle property is inherited from ToolStrip. One of the possible values for the LayoutStyle is HorizontalStackWithOverflow which is also the default setting. This setting should provide items with its Overflow property set to AsNeeded are moved to an overflow button. When I run the application and resize the form so

Menu Strip items enabling in runtime

夙愿已清 提交于 2019-12-11 16:56:13
问题 My menu Strip is like below. while loading time i want to make true for enable and visible property. Below is my code but that is not taking the preview and print option under the print option. foreach (ToolStripMenuItem i in menuStrip.Items) { for (int x = 0; x <= i.DropDownItems.Count-1; x++) { i.DropDownItems[x].Visible = true; i.DropDownItems[x].Enabled = true; } i.Available = true; i.Visible = true; i.Enabled = true; } 回答1: I'd suggest using some Extension Methods to: Get all descendants

Injecting a MenuStripItem to a derived class from the base constructor

心不动则不痛 提交于 2019-12-11 05:36:22
问题 I want to inject a MenuStrip Item or create a new one if it doesn't exists (but this is a different question) from the base constructor , the logic is the following: public class LocalizedForm : Form { public LocalizedForm() { Shown += (sender, e) => { MenuStrip menu = null; if (HasValidMenu(out menu)) LanguageManager.AttachMenu(menu); //Language Manager will inject MenuStripItems to the passed MenuStrip }; } protected bool HasValidMenu(out MenuStrip menu) { try { menu = Controls.OfType

Autohide MenuStrip - How to activate it when showing?

主宰稳场 提交于 2019-12-11 04:30:00
问题 I have a MenuStrip and I make it AutoHide using following code. It hides/shows prefect but when a control get focus, by pressing Alt key, MenuStrip shows but it is not active and there is not small underline under shortcut keys for example under 'F' for File , and pressing 'F' will not open it). How can I correctly active it? Note: I used MenuDeactivate instead of it but it did not work prefect. bool menuBarIsHide = true; bool altKeyIsDown = false; bool alwaysShowMenuBar=false; //KeyPreview

Color change for MenuItem

偶尔善良 提交于 2019-12-10 10:34:04
问题 I am programming a Backup Tool. On top of my tool I have a menustrip containing two toolstripmenuitems. I changed the colors a little bit to my expectations. Not focused the menu looks great: When I now click on the menu item "File" to open the context menu, the color changes to white and I am not able to read the text anymore: Can anyone please tell me where I can change that behavior? I use Visual Studio 2013 Ultimate, Windows Forms Application, Code is in C#. Here is the code: // //

mouseover event for menustripitem

可紊 提交于 2019-12-08 13:02:28
问题 I have some menustrip Items in my menustrip.I want to set the color of the menustrip item when the mouse is on the menustripitem.Is it possible to have mouseover event for a menustripitem. Thanks in Advance. 回答1: You need to create your own renderer and assign the MenuStrip.Renderer property. Here's an example, it is going to need some work to look better: public partial class Form1 : Form { public Form1() { InitializeComponent(); menuStrip1.Renderer = new MyRenderer(); } private class

Disabling a ToolStripMenuItem vs. disabling a MenuStrip.Item

亡梦爱人 提交于 2019-12-08 06:46:12
问题 When a user logs into my application, there are some menu items that I don't want every user to see. So I would like to either disable or make invisible the menu item. For example fileToolStripMenuItem is the first item in my menuStrip , when I try: fileToolStripMenuItem.Enabled = false; - this does not work menuStrip.Items[0].Enabled = false; - this does work Can anyone enlighten me as to the difference here? Also, I would like to be able to disable a drop down item from one of the menu

Winforms MenuStrip Underlined Hotkey Letter

寵の児 提交于 2019-12-06 01:27:17
问题 Typically the hotkey letters on a MenuStrip are underlined. (&File, &Open, etc) On a project I'm working on the underline shows up in the designer, but not at run time. I can't find the property that controls this. Anyone out there know? 回答1: In Windows, there is a setting whether or not to show the underline. To change the setting, Right click on the desktop Select "Properties" Click on the "Appearance" tab Click the "Effects" button Uncheck the box labeled "Hide underlined letters for