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属性返回实现OrderedDictionaryIOrderedDictionary接口的对象。 该 OrderedDictionary 对象包含 DictionaryEntry 表示记录字段的对象。 若要访问字段名称,请使用 Keys 对象的属性 OrderedDictionary 。 若要访问字段值,请使用 Values 该属性。
注释
作为快捷方式,可以使用对象的索引器 OrderedDictionary 直接访问字段值。 使用索引器的优点是它直接返回字段值。 依赖于字段顺序(例如 AccessDataSource)的数据源控件只能按索引访问字段值。