我有一个ToolStripButton用作单选按钮.选中时,按钮周围会出现蓝色轮廓,但没有背景颜色.对于用户来说,检查按钮是不够清楚的,因此我想更改背景颜色以使检查状态更加明显.
当Checked属性设置为true时,如何更改高亮颜色?
这是一段代码:
this.hideInactiveVehiclesToolstripButton.CheckOnClick = true;
this.hideInactiveVehiclesToolstripButton.ForeColor = System.Drawing.Color.Blue;
this.hideInactiveVehiclesToolstripButton.AutoSize = false;
this.hideInactiveVehiclesToolstripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.hideInactiveVehiclesToolstripButton.Image = global::ClientUI.Properties.Resources.toggleInactive;
this.hideInactiveVehiclesToolstripButton.ImageTransparentColor = System.Drawing.Color.Black;
this.hideInactiveVehiclesToolstripButton.Name = "hideInactiveVehiclesToolstripButton";
this.hideInactiveVehiclesToolstripButton.Size = new System.Drawing.Size(48, 48);
this.hideInactiveVehiclesToolstripButton.Text = "Hide Inactive Vehicles";
this.hideInactiveVehiclesToolstripButton.Click +=new System.EventHandler(this.hideInactiveVehiclesToolstripButton_Click);
Run Code Online (Sandbox Code Playgroud) 我怎样才能获得坐标ToolStripButton
?
我有一个带有包含按钮的工具条的Windows窗体应用程序.令人沮丧的是,我必须在任何按钮上单击两次才能在表单未聚焦时触发它.第一次单击似乎激活表单,然后第二次单击单击按钮(或者,我可以单击表单上的任意位置,然后单击按钮一次).如何修复此问题,即使表单未激活,我也可以直接点击按钮?
编辑:我觉得这应该是可行的,因为它适用于SQL Server Profiler和Visual Studio等程序(不是这些程序使用WinForms,但它表明它不是操作系统问题).
我ToolStrip
在C#winform应用程序中使用a .
当我将鼠标移到按钮上时,它会突出显示(透明的蓝色),我想改变这种颜色
我尝试使用自定义渲染器类
toolStrip1.Renderer = new MyRenderer();
....
class MyRenderer : ToolStripProfessionalRenderer
{
}
Run Code Online (Sandbox Code Playgroud)
但是,我不知道应该覆盖哪种方法来改变这种颜色.
我正在学习WPF并且一直在尝试创建工具条.是否有直接等效的WinForms ToolStripButton或正确的使用方法只是添加一个普通的按钮并格式化它?
我发现Microsoft有一个页面列出了WinForm控件及其WPF等价物,但没有提到toolstripbutton.
我试图用图像显示自己的自定义工具提示,但原生工具提示使一切都不好.它仍然出现在它不需要的地方.
我以这种方式创建ToolStripButton:
ToolStripButton btn = new ToolStripButton();
btn.Text = name;
btn.ToolTipText = null; //I also tried string.Empty, but no luck
Run Code Online (Sandbox Code Playgroud)
我还能做些什么来禁用它?
有一个带有ToolStrip的表单.此ToolStrip包含ToolStripButton.我想为此按钮分配图像:
this.btnSaveFile.Image = Bitmap.FromFile("C:\\Work\\Icons\\png\\save.png");
Run Code Online (Sandbox Code Playgroud)
仅当指定路径上有save.png时才有效.否则,我得到一个FileNotFound异常.
如果我通过表单设计器创建了一个表单,Visual Studio将创建如下代码:
this.toolStripButton9.Image = ((System.Drawing.Image) (resources.GetObject("toolStripButton9.Image")));
Run Code Online (Sandbox Code Playgroud)
toolStripButton9.Image这里不是真名.Visual Studio将我的文件save.png删除并将其转换为toolStripButton9.Image.
但我以编程方式创建了一个表单,没有Designer.我的问题是如何以编程方式将图像分配给ToolStripBotton?
我试图将图像添加到项目中,但它没有多大帮助.我不知道如何让Visual Studio抓住它并嵌入我的可执行文件中,这样我就不需要在指定位置使用此文件.
在MSDN,我只看到类似的解决方案是:
this.toolStripButton1.Image = Bitmap.FromFile("c:\\NewItem.bmp");
Run Code Online (Sandbox Code Playgroud)
但它并没有像我上面所说的那样起作用.我知道有一个简单的解决方案,但没有看到它.你能给我一个提示吗?
我想在用户光标悬停在特定的ToolStripButton上时更改用户的光标,而不是用于ToolStrip上的其他项目.如何设置按钮的光标?
我使用的ToolStrip
是一些ToolStripButton
s.
我想要的是能够闪烁其中一个按钮以引起用户的注意.
例如,如果他们对信息进行了更改,则需要单击" 保存"按钮.
如果这是一个普通的按钮,我可以使用a Timer
并定期更改,BackColor
但这不适用于ToolStrip
.
我可以创建一个Renderer子类并将其分配给ToolStrip
但是这似乎只在特定情况下使用 - 即它是由事件驱动的.
有没有人有任何想法?
有什么方法可以调整 ToolStrip 项目的图像大小吗?我已经设置了属性AutoSize = False
, ImageScaling = SizeToFit
&Size = 40, 40
但只有项目的框调整大小(在图像周围留有空格),并且图像大小仍然是默认大小。
然后我想出了使用BackgroundImage 插入图像而不是在Image 处插入图像。我可以调整/调整图像大小,但问题是当我运行系统并将光标指向 ToolStrip 项目时,该项目的图像消失。我找到了这个解决方案Resizing ToolStripButtons to fit Complete BackGround image但我不知道如何使用它来应用它vb.net
请帮助我。谢谢。