toolstrip

Mouse button in ToolStripMenuItem

痴心易碎 提交于 2019-12-24 19:25:51
问题 I have a context menu with a few items. One of the items has a submenu (or whatever it's called) with a few items (depends on what files it finds). What I want to do is when I left click one of the sub-items I want one thing to happen, and when I right click I want another thing to happen. My problem is that when I use the filesToolStripMenuItem_DropDownItemClicked, I don't get any MouseEventArgs in the parameter, so I can't find out which mouse button was used to click the item. I tried

problem with ToolStripSeparator

可紊 提交于 2019-12-24 19:19:26
问题 I have a toolstrip. For this toolstrip, I am adding ToolStripSplitButton and for this ToolStripSplitButton, I am adding toolstrip items, including ToolStripSeparator. In the click event of the toolstrip items I am retrieving items from the ToolStripSplitButton dropdown using below code. ToolStripDropDown tditems = ((System.Windows.Forms.ToolStripDropDownItem)(items[0])).DropDown; foreach (ToolStripMenuItem item in tditems.Items) { //something here } As the dropdown items have both toolstrip

ToolStrip vs MenuStrip - can I make their rendering identical?

旧街凉风 提交于 2019-12-24 16:20:56
问题 I need to display a toolstrip directly beneath a menustrip in my application, but setting RenderMode = Professional for each does not give identical results. They both show a background gradient, but not the same one. Is there some way to use menustrip rendering for the toolstrip, or vice versa? Or can someone advise how best to implement a gradient myself, that I can perform in a sub-classed renderer? ADDED LATER: Many thanks to nobugz for his answer below. Helpful material is also in this

Disable mouse capturing by Button

不打扰是莪最后的温柔 提交于 2019-12-24 13:52:13
问题 I create custom ContextMenuStrip with Button in it: ContextMenuStrip _contextMenu = new ContextMenuStrip(); _contextMenu.Items.Add(new ToolStripMenuItem("Item")); _contextMenu.Items.Add(new ToolStripControlHost(new Button())); When I open this context menu and move mouse over 'Item' it is highlighted. But after I clicked Button and then move mouse over 'Item' again it isn't highlighted anymore. Looks like Button captures mouse. How can I avoid this or release capturing after Button clicking?

.Net Toolstrip/MenuStrip Focus Issues

和自甴很熟 提交于 2019-12-24 02:08:24
问题 No matter what the scenario may be I'm able to recreate this annoying problem 100% of the time. Create a .Net project, C# or VB.Net. Add a ToolStrip control to the form. Create a few simple DropDownButton(s) that contain at least 2 menu items. Add any other controls you wish, a list box (populate it so it can receive focus correctly) and a ComboBox control. Either assign shortcut keys or enable TabStop on the ToolStrip so that it can receive focus by Keyboard. Run the project (Debug/Release,

How to add placeholder text to ToolStripTextBox?

╄→гoц情女王★ 提交于 2019-12-24 00:33:29
问题 In a WinForms project, I know how to add placeholder text to a regular textbox. But the ToolStripTextBox doesn't appear to be a regular textbox. For one, it doesn't expose the handle (which is what's required to set the placeholder text via Win API). So, how do I either set the placeholder text on a ToolStripTextBox or get its .Handle property? 回答1: ToolStripTextBox hosts a ToolStripTextBoxControl inside which is derived from TextBox and you can access the the hosted control using its TextBox

Moving toolstrip just a little too far left will create a new row if another toolstrip is on the same toolstrip panel

孤人 提交于 2019-12-23 10:24:00
问题 When I drag a toolstrip to the left (perhaps just to get it in the corner) with another toolstrip in that same toolstrip panel, the one I'm dragging jumps down to a 'new' row, as if I had moved it down. It's quite tricky to explain, so here's a couple of diagrams. Diagram A: I move the toolstrip to the left, and 'accidentally' go too far left (well only by a couple of dozen pixels, which users can easily do). Diagram B: This happens, the dragged toolstrip drops down a row. How can I prevent

How to remove this strange visual artifact in the corner of ToolStrip Winforms control?

自古美人都是妖i 提交于 2019-12-20 19:39:17
问题 Here is the picture that shows the problem. Take a look at the bottom right corner. Anyone knows how to get rid of it? Setting LayoutStyle to VerticalStackWithOverflow fixes it but also centers the items horizontally which I don't want. I just want a vertical stack like in the pic, but without that black line in the bottom right corner. 回答1: In the properties bar, set "RenderMode" to "System" or use .RenderMode = System.Windows.Forms.ToolStripRenderMode.System; Doing this will change the

.NET Multiple ToolStripButtons in a single ContextMenuItem

僤鯓⒐⒋嵵緔 提交于 2019-12-19 11:20:22
问题 I'm trying to create a ContextMenu where some items in the menu contain more than a single item. You could see it as trying to combine a ToolStrip and ContextMenuItem. I've tried using a ToolStripControlHost, but this creates problems with the focus. It basically requires you to click everything in the ToolStrip twice.. ContextMenuStrip m = new ContextMenuStrip(); ToolStrip tStrip = new ToolStrip(new ToolStripDropDownButton(), new ToolStripButton()); ToolStripControlHost tsHost = new

“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