語言

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

屬性值

記錄要插入的值。

範例

以下範例說明如何遍歷集合 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

Note

作為捷徑,你可以使用物件的 OrderedDictionary 索引器直接存取欄位值。 使用索引器的優點是它能直接回傳欄位值。 依賴欄位順序的資料來源控制(例如 AccessDataSource)只能透過索引存取欄位值。

適用於

另請參閱