toolstripbutton

Resizing ToolStrip item's image

风流意气都作罢 提交于 2020-01-25 07:03:46
问题 Is there any way I can fit/resize the image of ToolStrip item? I already set the property AutoSize = False , ImageScaling = SizeToFit & Size = 40, 40 but only the item's boxes resizing (leave spaces around image) and the image size is still with it's default size. I then came up with inserting the image using BackgroundImage instead of inserting it at Image. I can fit/resize the image but the problem is when I run my system and pointing the cursor on the ToolStrip item, the item's image

ToolStripButton: what's wrong with assigning an image programmatically

喜欢而已 提交于 2019-12-22 08:06:37
问题 There is a Form with a ToolStrip. This ToolStrip contains a ToolStripButton. I want to assign an image to this button: this.btnSaveFile.Image = Bitmap.FromFile("C:\\Work\\Icons\\png\\save.png"); It works only if there is save.png on specified path. Otherwise, I get an FileNotFound Exception. If I created a Form via Form Designer, Visual Studio would create a code like this: this.toolStripButton9.Image = ((System.Drawing.Image) (resources.GetObject("toolStripButton9.Image"))); toolStripButton9

Flashing ToolStripButton

别来无恙 提交于 2019-12-21 21:41:33
问题 I am using a ToolStrip with a number of ToolStripButton s. What I would like is to be able to flash one of the buttons to get the user's attention. For example, if they have made changes to information and need to click the Save button. If this were a normal button I could do this using a Timer and periodically changing the BackColor however this doesn't work with a ToolStrip . I could create a Renderer subclass and assign it to the ToolStrip but this appears to only get used in specific

.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

How do I programmatically wire up ToolStripButton events in C#?

こ雲淡風輕ζ 提交于 2019-12-17 21:32:19
问题 I'm programmatically adding ToolStripButton items to a context menu. That part is easy. this.tsmiDelete.DropDownItems.Add("The text on the item."); However, I also need to wire up the events so that when the user clicks the item something actually happens! How do I do this? The method that handles the click also needs to receive some sort of id or object that relates to the particular ToolStripButton that the user clicked. 回答1: Couldn't you just subscribe to the Click event? Something like

Resizing ToolStripButtons to fit complete BackGround image

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 21:50:03
问题 My goal is totally fit image in toolStripButton and toolStripDropDownButton. If a image in the button set with image property, I can not totally fit the image in the button. Because of margin, border, or something of the button.(I don't know exactly). So I try to set the image in the button with BackgroudImage property. After I adjust some property(like AutoSize, Size and so on...), I can fit image in button. but in this case, I can not see background image. It is disappear, when the mouse

Why is a NullReferenceException thrown when a ToolStrip button is clicked twice - openFileDialog.showDialog()?

北城余情 提交于 2019-12-10 18:57:56
问题 I created a clean WindowsFormsApplication solution, added a ToolStrip to the main form, and placed one button on it. I've added also an OpenFileDialog , so that the Click event of the ToolStripButton looks like the following: private void toolStripButton1_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); } I didn't change any other properties or events. The funny thing is that when I double-click the ToolStripButton (the second click must be quite fast, before the dialog opens

ToolStripButton: what's wrong with assigning an image programmatically

给你一囗甜甜゛ 提交于 2019-12-05 17:40:18
There is a Form with a ToolStrip. This ToolStrip contains a ToolStripButton. I want to assign an image to this button: this.btnSaveFile.Image = Bitmap.FromFile("C:\\Work\\Icons\\png\\save.png"); It works only if there is save.png on specified path. Otherwise, I get an FileNotFound Exception. If I created a Form via Form Designer, Visual Studio would create a code like this: this.toolStripButton9.Image = ((System.Drawing.Image) (resources.GetObject("toolStripButton9.Image"))); toolStripButton9.Image here is not a real name. Visual Studio takse my file save.png and transform it into

.NET Multiple ToolStripButtons in a single ContextMenuItem

谁说我不能喝 提交于 2019-12-01 12:04:08
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 ToolStripControlHost(tStrip); m.Items.Add(tsHost); Any thoughts on how to achieve this? A ContextMenuStrip is