0

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

2 に答える 2

2

BackColorプロパティはデフォルトでは機能しませんでした:これに応じて(ToolStripSplitButton BackColorは機能しません)、次の2つの手順に従います。

1)BackgroundImageを有効な画像に設定します。何でも構いません。ローカルリソースとして1ピクセルx1ピクセルのBMPを使用します。

2)BackgroundImageLayoutをNoneに設定します。これが、上記で使用する画像が重要ではない理由です。

結果:

ここに画像の説明を入力してください

于 2012-07-07T11:54:06.150 に答える