ListViewInsertEventArgs.Values 属性

定义

获取要插入的记录的值。

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

属性值

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 属性返回 OrderedDictionary 实现 IOrderedDictionary 接口的对象。 该 OrderedDictionary 对象包含 DictionaryEntry 表示记录字段的对象。 若要访问字段名称,请使用 Keys 对象的属性 OrderedDictionary 。 若要访问字段值,请使用该 Values 属性。

备注

作为快捷方式,可以使用对象的索引器 OrderedDictionary 直接访问字段值。 使用索引器的优点是它直接返回字段值。 依赖于字段顺序 ((如 AccessDataSource) )的数据源控件只能按索引访问字段值。

适用于

另请参阅