DataGridViewAutoSizeModeEventArgs DataGridViewAutoSizeModeEventArgs DataGridViewAutoSizeModeEventArgs DataGridViewAutoSizeModeEventArgs Class

定义

public ref class DataGridViewAutoSizeModeEventArgs : EventArgs
public class DataGridViewAutoSizeModeEventArgs : EventArgs
type DataGridViewAutoSizeModeEventArgs = class
    inherit EventArgs
Public Class DataGridViewAutoSizeModeEventArgs
Inherits EventArgs
继承
DataGridViewAutoSizeModeEventArgsDataGridViewAutoSizeModeEventArgsDataGridViewAutoSizeModeEventArgsDataGridViewAutoSizeModeEventArgs

示例

下面的代码示例演示如何处理AutoSizeRowsModeChanged事件。The following code example demonstrates how to process the AutoSizeRowsModeChanged event. 此代码示例摘自在如何:Windows 窗体 DataGridView 控件中的内容更改时自动调整单元格的大小。This code example is part of a larger example provided at How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control.

void WatchRowsModeChanges( Object^ /*sender*/, DataGridViewAutoSizeModeEventArgs^ modeEvent )
{
   Label^ label = dynamic_cast<Label^>(flowLayoutPanel1->Controls[ currentLayoutName ]);
   if ( modeEvent->PreviousModeAutoSized )
   {
      label->Text = String::Format( "changed to a different {0}{1}", label->Name, dataGridView1->AutoSizeRowsMode );
   }
   else
   {
      label->Text = String::Concat( label->Name, dataGridView1->AutoSizeRowsMode );
   }
}


private void WatchRowsModeChanges(object sender,
    DataGridViewAutoSizeModeEventArgs modeEvent)
{
    Label label =
        (Label)flowLayoutPanel1.Controls[currentLayoutName];

    if (modeEvent.PreviousModeAutoSized)
    {
        label.Text = "changed to a different " +
            label.Name +
            dataGridView1.AutoSizeRowsMode.ToString();
    }
    else
    {
        label.Text = label.Name +
            dataGridView1.AutoSizeRowsMode.ToString();
    }
}
Private Sub WatchRowsModeChanges(ByVal sender As Object, _
    ByVal modeEvent As DataGridViewAutoSizeModeEventArgs) _
    Handles DataGridView1.AutoSizeRowsModeChanged

    Dim label As Label = CType(FlowLayoutPanel1.Controls _
        (currentLayoutName), Label)

    If modeEvent.PreviousModeAutoSized Then
        label.Text = "changed to different " & label.Name & _
            DataGridView1.AutoSizeRowsMode.ToString()
    Else
        label.Text = label.Name & _
            DataGridView1.AutoSizeRowsMode.ToString()
    End If
End Sub

注解

当控件的AutoSizeRowsMode属性AutoSizeRowsModeChanged DataGridView值更改时, 将引发事件。The AutoSizeRowsModeChanged event is raised when the value of the AutoSizeRowsMode property of the DataGridView control changes. 当属性的值RowHeadersWidthSizeMode更改时, 将引发事件。RowHeadersWidthSizeModeChangedThe RowHeadersWidthSizeModeChanged event is raised when the value of the RowHeadersWidthSizeMode property changes.

有关如何处理事件的详细信息, 请参阅处理和引发事件For more information about how to handle events, see Handling and Raising Events.

构造函数

DataGridViewAutoSizeModeEventArgs(Boolean) DataGridViewAutoSizeModeEventArgs(Boolean) DataGridViewAutoSizeModeEventArgs(Boolean) DataGridViewAutoSizeModeEventArgs(Boolean)

初始化 DataGridViewAutoSizeModeEventArgs 类的新实例。Initializes a new instance of the DataGridViewAutoSizeModeEventArgs class.

属性

PreviousModeAutoSized PreviousModeAutoSized PreviousModeAutoSized PreviousModeAutoSized

获取一个值,此值指定是否之前已将 DataGridView 设置为自动调整大小。Gets a value specifying whether the DataGridView was previously set to automatically resize.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

适用于

另请参阅