ListViewInsertEventArgs.Values プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
挿入するレコードの値を取得します。
public:
property System::Collections::Specialized::IOrderedDictionary ^ Values { System::Collections::Specialized::IOrderedDictionary ^ get(); };
public System.Collections.Specialized.IOrderedDictionary Values { get; }
member this.Values : System.Collections.Specialized.IOrderedDictionary
Public ReadOnly Property Values As IOrderedDictionary
プロパティ値
挿入するレコードの値。
例
次の例は、 Values コレクションを反復処理する方法を示しています。 このコード例は、 ListViewInsertEventArgs クラスに提供されるより大きな例の一部です。
void ContactsListView_ItemInserting(Object sender, ListViewInsertEventArgs e)
{
// Iterate through the values to verify if they are not empty.
foreach (DictionaryEntry de in e.Values)
{
if (de.Value == null)
{
Message.Text = "Cannot insert an empty value.";
e.Cancel = true;
}
}
}
Sub ContactsListView_ItemInserting(ByVal sender As Object, _
ByVal e As ListViewInsertEventArgs)
' Iterate through the values to verify if they are not empty.
For Each de As DictionaryEntry In e.Values
If de.Value Is Nothing Then
Message.Text = "Cannot insert an empty value."
e.Cancel = True
End If
Next
End Sub
注釈
Values プロパティを使用して、挿入するレコードのフィールドの値にアクセスします。 たとえば、データ ソースに挿入される前に、レコードの値を検証または HTML エンコードできます。
Values プロパティは、IOrderedDictionary インターフェイスを実装するOrderedDictionary オブジェクトを返します。 OrderedDictionary オブジェクトには、レコードのフィールドを表すDictionaryEntryオブジェクトが含まれています。 フィールド名にアクセスするには、OrderedDictionary オブジェクトの Keys プロパティを使用します。 フィールド値にアクセスするには、 Values プロパティを使用します。
注
ショートカットとして、 OrderedDictionary オブジェクトのインデクサーを使用して、フィールド値に直接アクセスできます。 インデクサーを使用する利点は、フィールド値を直接返す点です。 フィールドの順序 ( AccessDataSource など) に依存するデータ ソース コントロールは、インデックスによってのみフィールド値にアクセスできます。