Aracılığıyla paylaş


Button.Width Özellik

Alır veya ayarlar genişliğini Button noktaları.

Ad alanı:  Microsoft.Office.Tools.Excel.Controls
Derleme:  Microsoft.Office.Tools.Excel.v4.0.Utilities (Microsoft.Office.Tools.Excel.v4.0.Utilities.dll içinde)

Sözdizimi

'Bildirim
Public Property Width As Double
    Get
    Set
public double Width { get; set; }

Özellik Değeri

Tür: System.Double
Genişliğini Button noktaları.

Açıklamalar

Yapılan değişiklikleri Width ve sol özellik değerlerini neden Right özelliği değeri Button değiştirin.

Button.Width Özelliği kullanır noktaları, oysa Control.Width özelliği kullanır piksel.

Negatif bir sayı veya 12288 daha yüksek bir sayı değeri ayarlayarak bir özel durum ancak sonuçları 1-12288 arasında belirlenen denetiminde durum oluşturmaz.

Örnekler

Aşağıdaki kod örneği, iki davranışı yeniden konumlandırma ve yeniden boyutlandırma karşılaştırır Button denetimleri çalışma. Click İlk düğmenin olay işleyicisini ayarlar Height ve Width Özellikler düğmesinin düğme boyutunu değiştirir, ancak çalışma aynı konumda kalır böylece Click İkinci düğmenin olay işleyicisini ayarlar Top ve Left Özellikler düğmesinin düğme, çalışma sayfasındaki konumunu değiştirir ancak kalır aynı boyutu.

Bu örnek, bir belge düzeyinde özelleştirme için bulunur.

Private Sub ModifySizeAndLocation()

    Dim SizeButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(25, 30, 100, 25, "SizeButton")
    SizeButton.Name = "SizeButton"
    SizeButton.Text = "Click to resize"
    AddHandler SizeButton.Click, AddressOf PointButtons_Click

    Dim LocationButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(25, 150, 100, 25, "LocationButton")
    LocationButton.Name = "LocationButton"
    LocationButton.Text = "Click to move"
    AddHandler LocationButton.Click, AddressOf PointButtons_Click
End Sub

' Represents the toggle states of the buttons.
Private toggleState1 As Boolean = True
Private toggleState2 As Boolean = True

Private Sub PointButtons_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim ClickedButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        CType(sender, Microsoft.Office.Tools.Excel.Controls.Button)

    ' Toggle the Height and Width of sizeButton.
    If ClickedButton.Name = "SizeButton" Then
        If toggleState1 Then
            ClickedButton.Height = 40
            ClickedButton.Width = 80
            toggleState1 = False
        Else
            ClickedButton.Height = 25
            ClickedButton.Width = 100
            toggleState1 = True
        End If

    ' Toggle the Left and Top of locationButton.
    Else
        If toggleState2 Then
            ClickedButton.Left = 50
            ClickedButton.Top = 100
            toggleState2 = False
        Else
            ClickedButton.Left = 25
            ClickedButton.Top = 150
            toggleState2 = True
        End If
    End If
End Sub
private void ModifySizeAndLocation()
{
    Microsoft.Office.Tools.Excel.Controls.Button sizeButton =
        this.Controls.AddButton(25, 30, 100, 25,
        "sizeButton");
    sizeButton.Name = "sizeButton";
    sizeButton.Text = "Click to resize";
    sizeButton.Click += new EventHandler(pointButtons_Click);

    Microsoft.Office.Tools.Excel.Controls.Button locationButton =
        this.Controls.AddButton(25, 150, 100, 25,
        "locationButton");
    locationButton.Name = "locationButton";
    locationButton.Text = "Click to move";
    locationButton.Click += new EventHandler(pointButtons_Click);
}

// Represents the toggle states of the buttons.
bool toggleState1 = true;
bool toggleState2 = true;

void pointButtons_Click(object sender, EventArgs e)
{
    Microsoft.Office.Tools.Excel.Controls.Button clickedButton =
        (Microsoft.Office.Tools.Excel.Controls.Button)sender;

    // Toggle the Height and Width of sizeButton.
    if (clickedButton.Name == "sizeButton")
    {
        if (toggleState1)
        {
            clickedButton.Height = 40;
            clickedButton.Width = 80;
            toggleState1 = false;
        }
        else
        {
            clickedButton.Height = 25;
            clickedButton.Width = 100;
            toggleState1 = true;
        }
    }

    // Toggle the Left and Top of locationButton.
    else
    {
        if (toggleState2)
        {
            clickedButton.Left = 50;
            clickedButton.Top = 100;
            toggleState2 = false;
        }
        else
        {
            clickedButton.Left = 25;
            clickedButton.Top = 150;
            toggleState2 = true;
        }
    }
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

Button Sınıf

Microsoft.Office.Tools.Excel.Controls Ad Alanı