ListViewUpdateEventArgs.NewValues 속성

정의

업데이트할 항목의 수정된 값이 들어 있는 사전을 가져옵니다.

public:
 property System::Collections::Specialized::IOrderedDictionary ^ NewValues { System::Collections::Specialized::IOrderedDictionary ^ get(); };
public System.Collections.Specialized.IOrderedDictionary NewValues { get; }
member this.NewValues : System.Collections.Specialized.IOrderedDictionary
Public ReadOnly Property NewValues As IOrderedDictionary

속성 값

IOrderedDictionary

업데이트할 항목의 수정된 값입니다.

예제

다음 예제에서는 사용 하는 방법을 보여 줍니다는 NewValues 속성을 사용자가 데이터 소스를 업데이트 하기 전에 모든 값을 제공한 있는지 확인 합니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ListViewUpdateEventArgs 클래스입니다.

void ContactsListView_ItemUpdating(Object sender, ListViewUpdateEventArgs e)
{
  // Cancel the update operation if any of the fields is empty
  // or null.
  foreach (DictionaryEntry de in e.NewValues)
  {
    // Check if the value is null or empty.
    if (de.Value == null || de.Value.ToString().Trim().Length == 0)
    {
      Message.Text = "Cannot set a field to an empty value.";
      e.Cancel = true;
    }
  }
  
  // Convert the email address to lowercase.
  String emailValue = e.NewValues["EmailAddress"].ToString();
  e.NewValues["EmailAddress"] = emailValue.ToLower();

}
Sub ContactsListView_ItemUpdating(ByVal sender As Object, ByVal e As ListViewUpdateEventArgs)
  
  ' Cancel the update operation if any of the fields is empty
  ' or null.
  For Each de As DictionaryEntry In e.NewValues
    ' Check if the value is null or empty
    If de.Value Is Nothing OrElse de.Value.ToString().Trim().Length = 0 Then
      Message.Text = "Cannot set a field to an empty value."
      e.Cancel = True
    End If
  Next
  
  ' Convert the email address to lowercase.
  Dim emailValue As String = e.NewValues("EmailAddress").ToString()    
  e.NewValues("EmailAddress") = emailValue.ToLower()
  
End Sub

설명

사용 된 NewValues 업데이트할 항목의 키가 아닌 필드의 수정 된 값에 액세스 하려면 속성 (사전)입니다.

참고

기본 키 값 또는 값을 업데이트할 경우 기본 키 필드 또는 필드를이 사전에 포함 됩니다. 기본 키 필드 또는 필드의 원래 값에 액세스 하려면 사용 된 Keys 속성입니다. 항목의 키가 아닌 필드의 원래 값에 액세스 하려면 사용 된 OldValues 속성입니다.

NewValues 속성 항목의 수정 된 필드 이름/값 쌍에 자동으로 채워집니다. 별도 항목에 추가 됩니다는 NewValues 항목의 모든 필드에 대 한 속성입니다.

항목의 필드 이름을 확인 하려면를 DictionaryEntry.Key 의 속성을 DictionaryEntry 에 포함 된 개체는 NewValues 사전입니다. 항목의 값을 확인 하려면 사용 된 DictionaryEntry.Value 속성입니다.

적용 대상

추가 정보