TableLayoutPanel.SetColumn(Control, Int32) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the column position of the specified child control.
public:
void SetColumn(System::Windows::Forms::Control ^ control, int column);
public void SetColumn (System.Windows.Forms.Control control, int column);
member this.SetColumn : System.Windows.Forms.Control * int -> unit
Public Sub SetColumn (control As Control, column As Integer)
- control
- Control
The control to move to another column.
- column
- Int32
The column to which control
will be moved.
The following code example uses the SetColumn method to swap two controls contained within a TableLayoutPanel control. The example assumes a TableLayoutPanel control with at least two rows.
private void swapControlsBtn_Click(
System.Object sender,
System.EventArgs e)
{
Control c1 = this.TableLayoutPanel1.GetControlFromPosition(0, 0);
Control c2 = this.TableLayoutPanel1.GetControlFromPosition(0, 1);
if( c1 != null && c2 != null )
{
this.TableLayoutPanel1.SetColumn(c2, 0);
this.TableLayoutPanel1.SetColumn(c1, 1);
}
}
Private Sub swapControlsBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles swapControlsBtn.Click
Dim c1 As Control = Me.TableLayoutPanel1.GetControlFromPosition(0, 0)
Dim c2 As Control = Me.TableLayoutPanel1.GetControlFromPosition(0, 1)
If c1 IsNot Nothing And c2 IsNot Nothing Then
Me.TableLayoutPanel1.SetColumn(c2, 0)
Me.TableLayoutPanel1.SetColumn(c1, 1)
End If
End Sub
The SetColumn method moves the control to another column in the TableLayoutPanel. The columns and rows have zero-based indexes. Setting the column position to -1 specifies that the control will flow to the first empty cell.
This method reapplies the table layout to all controls in the TableLayoutPanel.
This method is called by the Column
property, which the panel adds to its child controls at design time.
Termék | Verziók |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET-visszajelzés
A(z) .NET egy nyílt forráskód projekt. Visszajelzés adásához válasszon egy hivatkozást: