다음을 통해 공유


Button.Right 속성

Button의 오른쪽 가장자리와 문서의 왼쪽 가장자리 사이의 거리(포인트)를 가져옵니다.

네임스페이스:  Microsoft.Office.Tools.Word.Controls
어셈블리:  Microsoft.Office.Tools.Word.v4.0.Utilities(Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

구문

‘선언
Public ReadOnly Property Right As Single
    Get
public float Right { get; }

속성 값

형식: System.Single
Button 의 오른쪽 가장자리와 문서의 왼쪽 가장자리 사이의 거리(포인트)입니다.

설명

Right 속성 값은 Left 속성 값과 Width 속성 값의 합과 같습니다.

Button.Right 속성은 포인트를 사용하지만 Control.Right 속성은 픽셀을 사용합니다.

예제

다음 코드 예제에서는 Button 컨트롤의 Right 속성을 보여 줍니다. 이 예제에서는 sizeButton 및 locationButton이라는 Button 컨트롤을 문서에 추가합니다. sizeButton을 클릭하면 HeightWidth 속성이 조정되어 단추의 크기가 변경됩니다. locationButton을 클릭하면 TopLeft 속성이 조정되어 단추의 위치가 변경됩니다. 각 단추가 수정되면 이 예제에서는 클릭한 단추의 새로운 Right, Bottom, Height, Width, TopLeft 속성 값을 메시지 상자에 표시합니다.

이 예제는 문서 수준 사용자 지정을 위한 것입니다.

Private Sub ModifySizeAndLocation()

    ' Create a button that resizes when clicked.
    Dim SizeButton As Microsoft.Office.Tools.Word.Controls.Button = _
        Me.Controls.AddButton(25, 25, 80, 30, "SizeButton")
    SizeButton.Name = "SizeButton"
    SizeButton.Text = "Click to change size"
    AddHandler SizeButton.Click, AddressOf ModifyButtons_Click

    ' Create a button that moves when clicked.
    Dim LocationButton As Microsoft.Office.Tools.Word.Controls.Button = _
        Me.Controls.AddButton(50, 100, 80, 30, "LocationButton")
    LocationButton.Name = "LocationButton"
    LocationButton.Text = "Click to change location"
    AddHandler LocationButton.Click, AddressOf ModifyButtons_Click
End Sub

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

' Modify the appearance of the clicked button.
Private Sub ModifyButtons_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim ClickedButton As Microsoft.Office.Tools.Word.Controls.Button = _
        CType(sender, Microsoft.Office.Tools.Word.Controls.Button)

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

        ' Toggle the Left and Top of LocationButton.
    Else
        If toggleState2 Then
            ClickedButton.Left = 25
            ClickedButton.Top = 150
            toggleState2 = False
        Else
            ClickedButton.Left = 50
            ClickedButton.Top = 100
            toggleState2 = True
        End If
    End If

    ' Display the new Right and Bottom.
    MsgBox("Right: " & ClickedButton.Right.ToString() & _
        vbCr + "Bottom: " & ClickedButton.Bottom.ToString() & _
        vbCr + "Top: " & ClickedButton.Top.ToString() & _
        vbCr + "Left: " & ClickedButton.Left.ToString() & _
        vbCr + "Height: " & ClickedButton.Height.ToString() & _
        vbCr + "Width: " & ClickedButton.Width.ToString())
End Sub
private void ModifySizeAndLocation()
{
    // Create a button that resizes when clicked.
    Microsoft.Office.Tools.Word.Controls.Button sizeButton =
        this.Controls.AddButton(25, 25, 80, 30, "sizeButton");
    sizeButton.Name = "sizeButton";
    sizeButton.Text = "Click to change size";
    sizeButton.Click += new EventHandler(modifyButtons_Click);

    // Create a button that moves when clicked.
    Microsoft.Office.Tools.Word.Controls.Button locationButton =
        this.Controls.AddButton(50, 100, 80, 30, "locationButton");
    locationButton.Name = "locationButton";
    locationButton.Text = "Click to change location";
    locationButton.Click += new EventHandler(modifyButtons_Click);
}

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

// Modify the appearance of the clicked button.
void modifyButtons_Click(object sender, EventArgs e)
{
    Microsoft.Office.Tools.Word.Controls.Button clickedButton =
        (Microsoft.Office.Tools.Word.Controls.Button)sender;

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

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

    // Display the new property values.
    MessageBox.Show("Right: " +
        clickedButton.Right.ToString() +
        "\nBottom: " + clickedButton.Bottom.ToString() +
        "\nTop: " + clickedButton.Top.ToString() +
        "\nLeft: " + clickedButton.Left.ToString() +
        "\nHeight: " + clickedButton.Height.ToString() +
        "\nWidth: " + clickedButton.Width.ToString());
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

Button 클래스

Microsoft.Office.Tools.Word.Controls 네임스페이스