0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DataGridViewの編集コントロール(テキストボックス)に実装されたValidationは実行されない

Posted at

DataGridViewの編集コントロール(テキストボックス)にValidationを実装しても、セルの編集時には実行されない。

解説

テキストボックスの編集終了時のイベント発生順序

  1. Leave
  2. Validating
  3. Validated

フォーカスが外れてからValidationが行われる。

DataGridViewのセル編集終了時のイベント発生順序

  1. CellValidating
  2. CellValidated
  3. 編集コントロールの開放が開放され、IsCurrentCellInEditModeがfalseになる
  4. CellEndEdit
  5. CellLeave

Validationが行われてから、フォーカスが外れることなく編集コントロールが開放される。このため、テキストボックスのLeave以降のイベントは発生しない。

編集コントロールでValidationを行いたいなら、DataGridViewのイベントで行う必要がある。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?