Usando StatusStrip em C #
-
22-07-2019 - |
Pergunta
System.Windows.Forms.StatusStrip. Eu adicionei um StatusStrip para meu aplicativo Windows Forms, mas eu estou tendo alguns problemas.
Eu gostaria de ter um rótulo ancorado na esquerda e uma barra de progresso ancorado à direita na StatusStrip, mas não consigo encontrar uma maneira de definir essas propriedades.
Então eu pensei que talvez seja necessário criar dois StatusStrips e ancorá-los em ambos os lados da parte inferior do formulário ... Isso não deu certo; além disso, ele simplesmente não parece certo.
Solução
Apenas defina a propriedade Spring
no controle rótulo para True
e você deve ser bom para ir.
Outras dicas
O que você tem a fazer é definir a propriedade alinhamento de seu progressbar para a direita. Em seguida, defina o LayoutStyle do StatusStrip para 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;
Isto pode ser conseguido com o layout da tabela padrão para o StatusStrip simplesmente colocando outro rótulo entre o rótulo atual e sua progressBar e defina a propriedade da Primavera para true.
Você tentou o Alinhamento propriedade de conjunto ProgresBarToolStripItem ao direito?
Abra o Designer e conjunto this.toolStripStatusLabel1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;