TableLayoutPanel.RowStyles Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan kumpulan gaya baris untuk TableLayoutPanel.
public:
property System::Windows::Forms::TableLayoutRowStyleCollection ^ RowStyles { System::Windows::Forms::TableLayoutRowStyleCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.TableLayoutRowStyleCollection RowStyles { get; }
[<System.ComponentModel.Browsable(false)>]
member this.RowStyles : System.Windows.Forms.TableLayoutRowStyleCollection
Public ReadOnly Property RowStyles As TableLayoutRowStyleCollection
Nilai Properti
Yang TableLayoutRowStyleCollection berisi RowStyle untuk setiap baris dalam TableLayoutPanel kontrol.
- Atribut
Contoh
Contoh kode berikut mengatur RowStyle properti setiap baris saat Button diklik.
private void toggleRowStylesBtn_Click(
System.Object sender,
System.EventArgs e)
{
TableLayoutRowStyleCollection styles =
this.TableLayoutPanel1.RowStyles;
foreach( RowStyle style in styles )
{
if (style.SizeType==SizeType.Absolute)
{
style.SizeType = SizeType.AutoSize;
}
else if(style.SizeType==SizeType.AutoSize)
{
style.SizeType = SizeType.Percent;
// Set the row height to be a percentage
// of the TableLayoutPanel control's height.
style.Height = 33;
}
else
{
// Set the row height to 50 pixels.
style.SizeType = SizeType.Absolute;
style.Height = 50;
}
}
}
Private Sub toggleRowStylesBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles toggleRowStylesBtn.Click
Dim styles As TableLayoutRowStyleCollection = _
Me.TableLayoutPanel1.RowStyles
For Each style As RowStyle In styles
If style.SizeType = SizeType.Absolute Then
style.SizeType = SizeType.AutoSize
ElseIf style.SizeType = SizeType.AutoSize Then
style.SizeType = SizeType.Percent
' Set the row height to be a percentage
' of the TableLayoutPanel control's height.
style.Height = 33
Else
' Set the row height to 50 pixels.
style.SizeType = SizeType.Absolute
style.Height = 50
End If
Next
End Sub
Keterangan
RowStyles Gunakan properti untuk mengakses properti gaya baris tertentu. Anda dapat menggunakan anggota RowStyle kelas untuk mengatur karakteristik masing-masing baris dalam tabel.
TableLayoutPanel Saat kontrol mengatur barisnya, kontrol menetapkan prioritas untuk masing-masing RowStyle dalam urutan berikut:
Baris dengan RowStyle diatur ke Absolute dipertimbangkan terlebih dahulu, dan tinggi tetapnya dialokasikan.
Baris dengan RowStyle diatur ke AutoSize berukuran ke kontennya.
Ruang yang tersisa dibagi di antara baris dengan RowStyle diatur ke Percent.