DataGridViewBand.Frozen 属性
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示当用户滚动 DataGridView 时带区是否移动。
public:
virtual property bool Frozen { bool get(); void set(bool value); };
C#
public virtual bool Frozen { get; set; }
member this.Frozen : bool with get, set
Public Overridable Property Frozen As Boolean
如果带区不在视图中滚动,则为 true
;否则为 false
。 默认值为 false
。
下面的代码示例冻结列和行中的单元格带。 该示例还更改了冻结带的默认单元格样式,以指定哪些条带被冻结。 此代码示例是为 DataGridViewBand 类提供的一个更大示例的一部分。
// Freeze the first row.
void Button4_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
FreezeBand( dataGridView->Rows[ 0 ] );
}
void Button5_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
FreezeBand( dataGridView->Columns[ 1 ] );
}
void FreezeBand( DataGridViewBand^ band )
{
band->Frozen = true;
DataGridViewCellStyle^ style = gcnew DataGridViewCellStyle;
style->BackColor = Color::WhiteSmoke;
band->DefaultCellStyle = style;
}
C#
// Freeze the first row.
private void Button4_Click(object sender, System.EventArgs e)
{
FreezeBand(dataGridView.Rows[0]);
}
private void Button5_Click(object sender, System.EventArgs e)
{
FreezeBand(dataGridView.Columns[1]);
}
private static void FreezeBand(DataGridViewBand band)
{
band.Frozen = true;
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.BackColor = Color.WhiteSmoke;
band.DefaultCellStyle = style;
}
' Freeze the first row.
Private Sub Button4_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button4.Click
FreezeBand(dataGridView.Rows(0))
End Sub
Private Sub FreezeColumn(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button5.Click
FreezeBand(dataGridView.Columns(1))
End Sub
Private Shared Sub FreezeBand(ByVal band As DataGridViewBand)
band.Frozen = True
Dim style As DataGridViewCellStyle = New DataGridViewCellStyle()
style.BackColor = Color.WhiteSmoke
band.DefaultCellStyle = style
End Sub
当用户滚动浏览 DataGridView时,此属性可以保留一系列重要信息。 与冻结带相邻的波段将在冻结带上移动。
产品 | 版本 |
---|---|
.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, 10 |