datagridviewrow 行宽_DataGridView.AutoResizeRowHeadersWidth 方法 (System.Windows.Forms) | Microsoft Docs...

该方法根据指定行中标题内容的变化调整行标题宽度,提供不同的大小调整模式,以提高大量行时的性能。
摘要由CSDN通过智能技术生成

使用指定的大小调整模式,基于指定行中标题内容的更改调整行标题的宽度。Adjusts the width of the row headers based on changes to the contents of the header in the specified row and using the specified size mode.

public:

void AutoResizeRowHeadersWidth(int rowIndex, System::Windows::Forms::DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode);

public void AutoResizeRowHeadersWidth (int rowIndex, System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode);

member this.AutoResizeRowHeadersWidth : int * System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode -> unit

Public Sub AutoResizeRowHeadersWidth (rowIndex As Integer, rowHeadersWidthSizeMode As DataGridViewRowHeadersWidthSizeMode)

参数

rowIndex

内容已更改的行标题的索引。The index of the row header with the changed content.

例外

rowIndex 不在 0 到行数减 1 的有效范围内。rowIndex is not in the valid range of 0 to the number of rows minus 1.

示例

下面的代码示例演示如何根据第一个行标题的内容的更改调整行标题的宽度。The following code example illustrates how to resize the row header widths based on changes to the contents of the first row header.

void SizeFirstRowHeaderToAllHeaders( Object^ /*sender*/, EventArgs^ /*e*/ )

{

dataGridView1->AutoResizeRowHeadersWidth(0, DataGridViewRowHeadersWidthSizeMode::AutoSizeToAllHeaders);

}private void SizeFirstRowHeaderToAllHeaders(Object sender, EventArgs e)

{

dataGridView1.AutoResizeRowHeadersWidth(

0, DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);

}Private Sub SizeFirstRowHeaderToAllHeaders(ByVal sender As Object, _

ByVal e As System.EventArgs) Handles Button8.Click

DataGridView1.AutoResizeRowHeadersWidth( _

DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders)

End Sub

注解

如果您想要控制行标题调整行标题的时间,如果用户编辑或更改了绑定数据源,则此方法很有用。This method is useful if you want to control when the row headers resize if only the contents of the header in the specified row have changed as a result of user edits or changes to a bound data source. 如果内容更改需要行标题,则只对每个方法调用调整行标题的宽度;如果后续行标题的内容发生更改,则不会自动调整行标题。The width of the row headers is adjusted only once per method call if the content change requires it; if the contents of the row headers later change, the row headers will not automatically adjust. 若要将行标题设置为在其内容更改时自动调整大小,请使用 RowHeadersWidthSizeMode 属性。To set the row headers to automatically resize when their contents change, use the RowHeadersWidthSizeMode property.

此方法允许您指定一个调整大小模式,该模式基于有限的一组标头中的值(例如,仅显示的行中的值)计算新的宽度。This method lets you specify a sizing mode that calculates the new width based on values in a limited set of headers, such as those in displayed rows only. 这会提高控件包含大量行时的性能。This improves performance when the control contains a large number of rows.

另请参阅

适用于

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值