GrapeCity MultiRow for Windows Forms 11.0J
セルのスタイルによる通知(CellStyleNotify)

CellStyleNotifyを使用すると、検証エラーをセルのスタイルの変更によって通知できます。たとえば、セルの背景色や前景色を赤に変更できます。
デザイナによる設定
デザイナでセルの検証と共にCellStyleNotifyを使用するには、次のように操作します。

  1. 値を検証するセルを選択する。(例: textBoxCell1)
  2. プロパティウィンドウでValidatorsプロパティを選択し、[...]ボタンをクリックする。
  3. 表示されたCellValidatorコレクションエディタで左上のコンボボックスから「RequiredFieldValidator」を選択し、[追加]をクリックする。
  4. 画面右のプロパティグリッドでActionsプロパティを選択し、[...]ボタンをクリックする。
  5. 表示されたCellValidateActionコレクションエディタでCellStyleNotifyを追加する。
  6. [メンバ]リストでCellStyleNotifyが選択されていることを確認する。画面右のプロパティグリッドでInvalidCellStyleプロパティに任意のセルスタイルを設定する(例:BackColorプロパティをRedに設定する)。
  7. [OK]ボタンをクリックしてCellValidateActionコレクションエディタを閉じる。
  8. [OK]ボタンをクリックしてCellValidatorコレクションエディタを閉じる。
  9. デザイナのドキュメントウィンドウのタブを「実行時」に切り替える。
  10. textBoxCell1を変更せずに次のセルに移動して検証エラーが表示されることを確認する。
コーディングによる設定
次のコードは、文字列型セルの値が空白のとき検証エラーとしてセルの背景色を変更します。

Imports GrapeCity.Win.MultiRow

Dim TextBoxCell1 As New TextBoxCell()
Dim RequiredFieldValidator1 As New RequiredFieldValidator()
Dim CellStyleNotify1 As New CellStyleNotify()
CellStyleNotify1.InvalidCellStyle.BackColor = Color.Red
RequiredFieldValidator1.Actions.Add(CellStyleNotify1)
TextBoxCell1.Validators.Add(RequiredFieldValidator1)

Dim cells As Cell() = {TextBoxCell1}
GcMultiRow1.Template = Template.CreateGridTemplate(cells)
GcMultiRow1.RowCount = 10
using GrapeCity.Win.MultiRow;

TextBoxCell textBoxCell1 = new TextBoxCell();
RequiredFieldValidator requiredFieldValidator1 = new RequiredFieldValidator();
CellStyleNotify cellStyleNotify1 = new CellStyleNotify();
cellStyleNotify1.InvalidCellStyle.BackColor = Color.Red;
requiredFieldValidator1.Actions.Add(tipNotify1);
textBoxCell1.Validators.Add(requiredFieldValidator1);

Cell[] cells = { textBoxCell1 };
gcMultiRow1.Template = Template.CreateGridTemplate(cells);
gcMultiRow1.RowCount = 10;
   
関連トピック

 

 


© 2008 GrapeCity inc. All rights reserved.