DataGridView.RowErrorTextNeeded イベント
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
行のエラー テキストが必要な場合に発生します。
public:
event System::Windows::Forms::DataGridViewRowErrorTextNeededEventHandler ^ RowErrorTextNeeded;
public event System.Windows.Forms.DataGridViewRowErrorTextNeededEventHandler RowErrorTextNeeded;
public event System.Windows.Forms.DataGridViewRowErrorTextNeededEventHandler? RowErrorTextNeeded;
member this.RowErrorTextNeeded : System.Windows.Forms.DataGridViewRowErrorTextNeededEventHandler
Public Custom Event RowErrorTextNeeded As DataGridViewRowErrorTextNeededEventHandler
イベントの種類
例
次のコード例では、このメンバーの使用方法を示します。 この例では、イベント ハンドラーがイベントの RowErrorTextNeeded 発生を報告します。 このレポートは、イベントが発生したタイミングを確認するのに役立ち、デバッグに役立ちます。 複数のイベントまたは頻繁に発生するイベントを報告するには、 を Console.WriteLine に置き換えるかMessageBox.Show、複数行TextBoxにメッセージを追加することを検討してください。
コード例を実行するには、 という名前DataGridView1
の型DataGridViewのインスタンスを含むプロジェクトに貼り付けます。 次に、イベント ハンドラーがイベントに関連付けられていることを確認します RowErrorTextNeeded 。
private void DataGridView1_RowErrorTextNeeded(Object sender, DataGridViewRowErrorTextNeededEventArgs e) {
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ErrorText", e.ErrorText );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "RowErrorTextNeeded Event" );
}
Private Sub DataGridView1_RowErrorTextNeeded(sender as Object, e as DataGridViewRowErrorTextNeededEventArgs) _
Handles DataGridView1.RowErrorTextNeeded
Dim messageBoxVB as New System.Text.StringBuilder()
messageBoxVB.AppendFormat("{0} = {1}", "ErrorText", e.ErrorText)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex)
messageBoxVB.AppendLine()
MessageBox.Show(messageBoxVB.ToString(),"RowErrorTextNeeded Event")
End Sub
注釈
イベントは RowErrorTextNeeded 、コントロールの プロパティが DataSource 設定されているか、 DataGridView その VirtualMode プロパティが である true
場合にのみ発生します。 イベントの RowErrorTextNeeded 処理は、その状態と含まれる値に応じて行のエラーを特定する場合に便利です。
イベントを RowErrorTextNeeded 処理し、ハンドラーでエラー テキストを指定すると、 プロパティが に設定されていない限り ShowRowErrors 、エラー グリフが行ヘッダーに false
表示されます。 ユーザーがエラー グリフの上にマウス ポインターを移動すると、エラー テキストがツールヒントに表示されます。
イベントは RowErrorTextNeeded 、 プロパティの DataGridViewRow.ErrorText 値が取得されるたびにも発生します。
プロパティを DataGridViewRowErrorTextNeededEventArgs.RowIndex 使用して、行の状態または含まれる値を確認し、この情報を使用してプロパティを DataGridViewRowErrorTextNeededEventArgs.ErrorText 変更または変更できます。 このプロパティは、イベント値がオーバーライドする row ErrorText プロパティの値で初期化されます。
大量のデータを RowErrorTextNeeded 操作するときにイベントを処理して、複数の行の行 ErrorText 値を設定するパフォーマンスの低下を回避します。 詳細については、「 Windows フォーム DataGridView コントロールを拡張するための推奨される手順」を参照してください。
イベントを処理する方法の詳細については、次を参照してください。処理とイベントの発生します。
適用対象
こちらもご覧ください
.NET