TableLayoutPanel.GetColumnSpan(Control) 메서드

정의

지정된 자식 컨트롤에 의해 확장되는 열 수를 반환합니다.

public:
 int GetColumnSpan(System::Windows::Forms::Control ^ control);
public int GetColumnSpan (System.Windows.Forms.Control control);
member this.GetColumnSpan : System.Windows.Forms.Control -> int
Public Function GetColumnSpan (control As Control) As Integer

매개 변수

control
Control

TableLayoutPanel의 자식 컨트롤입니다.

반환

Int32

자식 컨트롤에 의해 확장되는 열 수입니다. 기본값은 1입니다.

예제

다음 코드 예제에서는 및 메서드를 GetColumnSpan 사용하여 컨트롤TableLayoutPanel의 너비를 Button SetColumnSpan 설정합니다.

private void toggleSpanBtn_Click(
    System.Object sender, 
    System.EventArgs e)
{
    Control c = this.TableLayoutPanel1.GetControlFromPosition(0, 0);

    if ( c != null )
    {
        int xSpan = this.TableLayoutPanel1.GetColumnSpan(c);
        int ySpan = this.TableLayoutPanel1.GetRowSpan(c);

        if (xSpan>1)
        {
            xSpan = 1;
            ySpan = 1;
        }
        else
        {
            xSpan = 2;
            ySpan = 2;
        }

        this.TableLayoutPanel1.SetColumnSpan(c, xSpan);
        this.TableLayoutPanel1.SetRowSpan(c, ySpan);
    }
}
Private Sub toggleSpanBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles toggleSpanBtn.Click

    Dim c As Control = Me.TableLayoutPanel1.GetControlFromPosition(0, 0)

    If c IsNot Nothing Then

        Dim xSpan As Integer = Me.TableLayoutPanel1.GetColumnSpan(c)
        Dim ySpan As Integer = Me.TableLayoutPanel1.GetRowSpan(c)

        If xSpan > 1 Then

            xSpan = 1
            ySpan = 1

        Else

            xSpan = 2
            ySpan = 2

        End If

        Me.TableLayoutPanel1.SetColumnSpan(c, xSpan)
        Me.TableLayoutPanel1.SetRowSpan(c, ySpan)

    End If

End Sub

설명

열 스패닝은 피어보다 훨씬 더 넓은 컨트롤의 위치를 지정하는 데 유용한 경우가 많습니다.

이 메서드는 디자인 타임에 ColumnSpan 패널이 자식 컨트롤에 추가하는 속성에 의해 호출됩니다.

적용 대상

추가 정보