DataGridView.AutoSizeRowsModeChanged DataGridView.AutoSizeRowsModeChanged DataGridView.AutoSizeRowsModeChanged DataGridView.AutoSizeRowsModeChanged Event

定義

DataGridViewAutoSizeRowsMode プロパティの値が変更された場合に発生します。Occurs when the value of the DataGridViewAutoSizeRowsMode property changes.

public:
 event System::Windows::Forms::DataGridViewAutoSizeModeEventHandler ^ AutoSizeRowsModeChanged;
public event System.Windows.Forms.DataGridViewAutoSizeModeEventHandler AutoSizeRowsModeChanged;
member this.AutoSizeRowsModeChanged : System.Windows.Forms.DataGridViewAutoSizeModeEventHandler 
Public Custom Event AutoSizeRowsModeChanged As DataGridViewAutoSizeModeEventHandler 

次のコード例は、このイベントの使用方法を示しています。The following code example illustrates the use of this event. この例は、次の方法で使用できる大きな例の一部です。Windows フォーム DataGridView コントロールでコンテンツが変更されたときにセルのサイズを自動的に変更します。This example is part of a larger example available in 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

注釈

イベントを処理する方法の詳細については、次を参照してください。処理とイベントの発生します。For more information about how to handle events, see Handling and Raising Events.

適用対象

こちらもご覧ください