toolstripmenu

Do not close ToolStripMenu on clicking in winforms

亡梦爱人 提交于 2021-01-27 15:19:25
问题 I work on a c# winform project that the main toolstripmenu have not to be hide after user clicks on its item, how can I do that? 回答1: Set the AutoClose property of the parent menu item to prevent the menu strip from closing. To demonstrate: ToolStripMenuItem file = new ToolStripMenuItem("File"); file.DropDown.AutoClose = false; file.DropDownItems.Add("New"); file.DropDownItems.Add("Open"); file.DropDownItems.Add("Exit"); MenuStrip ms = new MenuStrip(); ms.Items.Add(file); this.Controls.Add(ms

Do not close ToolStripMenu on clicking in winforms

為{幸葍}努か 提交于 2021-01-27 14:40:37
问题 I work on a c# winform project that the main toolstripmenu have not to be hide after user clicks on its item, how can I do that? 回答1: Set the AutoClose property of the parent menu item to prevent the menu strip from closing. To demonstrate: ToolStripMenuItem file = new ToolStripMenuItem("File"); file.DropDown.AutoClose = false; file.DropDownItems.Add("New"); file.DropDownItems.Add("Open"); file.DropDownItems.Add("Exit"); MenuStrip ms = new MenuStrip(); ms.Items.Add(file); this.Controls.Add(ms

how can I change toolstripmenuitem border color?

一笑奈何 提交于 2020-02-28 06:11:12
问题 I made a form like this (language c# - VisualStudio2012): http://i.stack.imgur.com/5GEY1.jpg How can I change the border color of toolstripmenuitem from white to another, or disable it ? code: class CustomProfessionalColors : ProfessionalColorTable { public override Color MenuItemSelected { get { return Color.FromArgb(51, 51, 52); } } public override Color MenuBorder { get { return Color.Black; } } //fill màu item của menu khi mouse enter public override Color MenuItemSelectedGradientBegin {

How to find toolstripmenuItem with name

十年热恋 提交于 2019-12-24 03:31:06
问题 I have set visible property of my menuStrip1 items to false as foreach (ToolStripMenuItem itm in menuStrip1.Items) { itm.Visible = false; } Now I know the Names of toolStripMenuItem and dropDownItem of the menustrip1. How to can I activate the required toolStripMenuItem and dropDownItem . I have string mnItm = "SalesToolStripMenuItem"; string ddItm = "invoiceToolStripMenuItem"; Now I want to set visible true to these two( toolStripMenuItem and dropDownItem ) items. How can I do that? I know

c# winforms toolstripmenuitem change background

若如初见. 提交于 2019-12-23 01:26:49
问题 OK, someone please tell me why this is not working. I have a simple MenuStrip in winforms app (c#). It has ToolStripMenuItems. In the properties window of the designer, I select BackColor = White. In Desginer.cs file I can see it. Running the app, the background color is Control (grey). What is going? Why is the backcolor not white? Thanks EDIT This is the code from the Designer.cs: this.menuRefresh.BackColor = System.Drawing.Color.White; EDIT2: In the code, after loading the form (in the

DropDownMenuItem check should uncheck other DropDownMenuItems

梦想的初衷 提交于 2019-12-22 01:15:39
问题 I'm creating a ToolStripMenuItem's DropDownItems at runtime. Me.mnuExtrasSecondaryLCID.DropDownItems.Clear() Dim iCount As Integer = -1 For Each nLang As clsLanguage In g_LCIDs If nLang.IsLeader Then iCount += 1 Dim n As New ToolStripMenuItem n.Name = "mnuSecondaryLCID" & iCount.ToString() n.Text = nLang.Title n.Tag = nLang.LCID n.Available = True n.CheckOnClick = True Me.mnuExtrasSecondaryLCID.DropDownItems.Add(n) AddHandler n.Click, AddressOf Me.SecondaryLCIDClick End If Next This works

C# shortcut key underscore not displayed in built application

杀马特。学长 韩版系。学妹 提交于 2019-12-18 05:11:31
问题 I have a small problem with .Net 4.0 ToolStripMenuItem caption. I want it to underscore the Shortcut (access) key letter in the item text. I used the ampersand sign in the item text field: '&New map', and it looks fine in the editor: But, when I build the application, the underscores disappear: Does anyone know why does it happen and how to make the underscored display in the built form? 回答1: As mentioned in other answers, this the default behaviour. Accelerators are being shown only after

Adding to strip menu at run time

对着背影说爱祢 提交于 2019-12-14 03:13:05
问题 OK I have a list of strings (file names in fact), that i want to create a file menu dynamical form. So taking my list of file names, first code strips of the directory string and file sufix (for bonus question how can I wrap the two remove lines up in to one ?) List<string> test_ = populate.Directorylist(); foreach (var file_ in test_) { int len_ = file_.Length; string filename_ = file_.Remove(0, 8); filename_ = filename_.Remove(filename_.Length - 4).Trim(); ToolStripItem subItem = new

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)

How do I close a toolstripmenuitem that is set to autoclose = false?

主宰稳场 提交于 2019-12-12 04:55:25
问题 I have a menu of items that the user can toggle. I wanted the menu to stay open so the user can check all the items they want. I set autoclose = false and now that works great. However, I also cannot close the window now lol. I tried clicking off of the menu onto the form, hitting escape, hitting the menu item, hitting the keycombo for the menu, nothing works. Ideally, I'd like the user to be able to just click the form or basically anything but the menu to close it or press escape. How would