1

How to change the back color of the tool strip split button in windows forms application. 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);
Murugesan
  • 37
  • 3
  • 6
  • possible duplicate of [How to change System.Windows.Forms.ToolStripButton highlight/background color when checked?](http://stackoverflow.com/questions/2097164/how-to-change-system-windows-forms-toolstripbutton-highlight-background-color-wh) – Ahmad Feb 03 '15 at 06:52
  • you can find the ansswer here [https://stackoverflow.com/a/54088322/5627499](https://stackoverflow.com/a/54088322/5627499) – ajd.nas Jan 08 '19 at 09:05

2 Answers2

2

It's BackColor property did not work by default: Accorthing this (ToolStripSplitButton BackColor does not work), follow these two steps:

1) Set BackgroundImage to a valid image. It does not matter what. I use a 1 pixel x 1 pixel BMP as local resource.

2) Set BackgroundImageLayout to None. This is why it does not matter what image you use above.

Result:

enter image description here

KF2
  • 9,887
  • 8
  • 44
  • 77
1

You can use a custom renderer for the toolstrip, you can found a sample in this answer for a similar question.

Community
  • 1
  • 1
Ahmad
  • 8,811
  • 11
  • 76
  • 141
  • **How?** Neither `ToolStripButton` nor `ToolStripSplitbutton` have a `Renderer` property. Only `MenuStrip` and `ToolStrip` have that. How would you assign the renderer mentioned in the link? – Matt Aug 01 '23 at 09:12