WindowsFormアプリケーションのプログレスバーの色がデフォルトで緑に固定されている
色を変える手順
-
Program.cs
を修正する - ゲージの見た目が点線になるので
Form1.Designer.cs
から修正をする
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DesktopMascot_Share_Doraemon {
public static class Program {
public static Form1 mainForm;
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main() {
//Application.EnableVisualStyles();//ここをコメントアウトする
Application.SetCompatibleTextRenderingDefault(false);
mainForm = new Form1();
Application.Run(mainForm);
}
}
}
このままだと表示が変なので、ブロックじゃなくて連続のバーにしたい場合はstyleプロパティーを設定します。
progressBar1.Style = ProgressBarStyle.Continuous;
Form1.Designer.cs
namespace DesktopMascot_Share_Doraemon {
partial class Form1 {
/// <summary>
/// 必要なデザイナー変数です。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
/// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows フォーム デザイナーで生成されたコード
/// <summary>
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
/// コード エディターで変更しないでください。
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.contextMenuStrip1 = new
...etc
// progressBar1
//
this.progressBar1.BackColor = System.Drawing.Color.White;
this.progressBar1.Dock = System.Windows.Forms.DockStyle.Fill;
this.progressBar1.Location = new System.Drawing.Point(0, 0);
this.progressBar1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.progressBar1.Name = "progressBar_Physical";
this.progressBar1.Size = new System.Drawing.Size(57, 20);
this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
this.progressBar1.TabIndex = 3;
...etc
}
#endregion
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
...etc
}
}