Utilizzo di StatusStrip in C #
-
22-07-2019 - |
Domanda
Prendi in considerazione System.Windows.Forms.StatusStrip . Ho aggiunto StatusStrip alla mia applicazione Windows Forms, ma sto riscontrando alcuni problemi.
Vorrei avere un'etichetta ancorata a sinistra e una barra di avanzamento ancorata a destra in StatusStrip, ma non riesco a trovare un modo per impostare queste proprietà.
Ho quindi pensato che potrei aver bisogno di creare due StatusStrip e ancorarli su entrambi i lati del fondo del modulo ... Che non è andato fuori; oltre a ciò, semplicemente non sembra giusto.
Soluzione
Basta impostare la proprietà Spring
sul controllo etichetta su True
e dovresti essere pronto per andare.
Altri suggerimenti
Quello che devi fare è impostare la proprietà di allineamento della barra di avanzamento a destra. Quindi impostare LayoutStyle di StatusStrip su HorizontalStackWithOverflow.
private void InitializeComponent()
{
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.toolStripProgressBar1});
this.statusStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
this.statusStrip1.Location = new System.Drawing.Point(0, 250);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(467, 22);
this.statusStrip1.TabIndex = 0;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(117, 17);
this.toolStripStatusLabel1.Text = "toolStripStatusLabel1";
//
// toolStripProgressBar1
//
this.toolStripProgressBar1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.toolStripProgressBar1.Name = "toolStripProgressBar1";
this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 16);
}
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
Questo può essere ottenuto con il layout di tabella predefinito per statusStrip semplicemente inserendo un'altra etichetta tra l'etichetta corrente e progressBar e impostando la proprietà Spring su true.
Hai provato Proprietà di allineamento di ProgresBarToolStripItem impostato su Giusto ?
Apri Designer e imposta this.toolStripStatusLabel1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;