Share via


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 屬性。

注意

做為快捷方式,您可以使用 物件的索引子 OrderedDictionary 直接存取域值。 使用索引子的優點是它會直接傳回域值。 依賴欄位順序的資料來源控制項 (,例如 AccessDataSource) 只能依索引存取域值。

適用於

另請參閱