Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações. |
Tradução
Original
|
Classe ToolStripButton
Representa um selecionável ToolStripItem que pode conter texto e imagens.
Assembly: System.Windows.Forms (em System.Windows.Forms.dll)
Use ToolStripButton Para criar um botão de barra de ferramentas que oferece suporte para texto e imagens. Use o ToolStripItem.ImageAlign e ToolStripItem.TextAlign propriedades para obter ou conjunto o posicionamento do ToolStripButton imagens e texto.
Você pode exibir um ToolStripButton com borda vários estilos e você pode usá-lo para representar e ativar estados operacionais. Você também pode definir que ele tenha o foco por padrão.
Embora ToolStripButton substitui e estende o ToolBarButton controle de versões anteriores, ToolBarButton é mantido para compatibilidade com versões anteriores e para uso futuro.
O exemplo de código a seguir mostra dois ToolStripButton controles com imagem e texto em um ToolStrip. Clicking the NewToolStripButton displays a message box.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Windows.Forms; namespace WindowsApplication11 { publicclass Form1 : Form { private ToolStripButton toolStripButton1; private ToolStripButton toolStripButton2; private ToolStrip toolStrip1; public Form1() { InitializeComponent(); } [STAThread] staticvoid Main() { Application.EnableVisualStyles(); Application.Run(new Form1()); } privatevoid InitializeComponent() { this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); this.toolStrip1.SuspendLayout(); this.SuspendLayout(); // // toolStrip1// this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripButton1, this.toolStripButton2}); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.TabIndex = 0; this.toolStrip1.Text = "toolStrip1"; // // toolStripButton1//this.toolStripButton1.Image = Bitmap.FromFile("c:\\NewItem.bmp"); this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText; this.toolStripButton1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.toolStripButton1.Name = "toolStripButton1"; this.toolStripButton1.Text = "&New"; this.toolStripButton1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click); // // toolStripButton2// this.toolStripButton2.Image = Bitmap.FromFile("c:\\OpenItem.bmp"); this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText; this.toolStripButton2.Name = "toolStripButton2"; this.toolStripButton2.Text = "&Open"; this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click); // // Form1// this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.Add(this.toolStrip1); this.Name = "Form1"; this.toolStrip1.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } privatevoid toolStripButton1_Click(object sender, EventArgs e) { MessageBox.Show("You have mail."); } privatevoid toolStripButton2_Click(object sender, EventArgs e) { // Add the response to the Click event here. } } }
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.ToolStripItem
System.Windows.Forms.ToolStripButton
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
o.NET Framework e.NET Compact Framework não oferecem suporte a todas as versões de cada plataforma. Para obter uma lista de versões suportadas, consulte Requisitos de sistema do .NET framework.