[英]How to change the back color of tool strip split button in windows form c#
How to change the back color of the tool strip split button in windows forms application. 如何更改Windows窗体应用程序中工具条拆分按钮的背面颜色。 Back color property not working.. This the code in designer class..
背面颜色属性不起作用..这是设计器类中的代码..
this.level.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
this.level.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.level.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.autoToolStripMenuItem1,
this.loadToolStripMenuItem1});
this.level.Image = global::PACS.Properties.Resources.winlevel;
this.level.ImageTransparentColor = System.Drawing.Color.Red;
this.level.Margin = new System.Windows.Forms.Padding(1, 1, 1, 2);
this.level.Name = "level";
this.level.Size = new System.Drawing.Size(53, 43);
this.level.Text = "Level";
this.level.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay;
this.level.Paint += new System.Windows.Forms.PaintEventHandler(this.Window_level_Paint);
this.level.Click += new System.EventHandler(this.Window_level_Click);
It's BackColor property did not work by default: Accorthing this ( ToolStripSplitButton BackColor does not work ), follow these two steps: 它的BackColor属性默认不起作用:Accorthing this( ToolStripSplitButton BackColor不起作用 ),请按照以下两个步骤操作:
1) Set BackgroundImage to a valid image. 1)将BackgroundImage设置为有效图像。 It does not matter what.
什么都没关系。 I use a 1 pixel x 1 pixel BMP as local resource.
我使用1像素x 1像素BMP作为本地资源。
2) Set BackgroundImageLayout to None. 2)将BackgroundImageLayout设置为None。 This is why it does not matter what image you use above.
这就是为什么上面使用的图像并不重要。
Result: 结果:
您可以使用自定义渲染器作为toolstrip
,您可以在此答案中找到类似问题的示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.