簡體   English   中英

如何在windows窗體c#中更改工具條分割按鈕的背面顏色

[英]How to change the back color of tool strip split button in windows form c#

如何更改Windows窗體應用程序中工具條拆分按鈕的背面顏色。 背面顏色屬性不起作用..這是設計器類中的代碼..

        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);

它的BackColor屬性默認不起作用:Accorthing this( ToolStripSplitButton BackColor不起作用 ),請按照以下兩個步驟操作:

1)將BackgroundImage設置為有效圖像。 什么都沒關系。 我使用1像素x 1像素BMP作為本地資源。

2)將BackgroundImageLayout設置為None。 這就是為什么上面使用的圖像並不重要。

結果:

在此輸入圖像描述

您可以使用自定義渲染器作為toolstrip ,您可以在此答案中找到類似問題的示例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM