ErrorProvider.DataMember 속성

정의

모니터링할 데이터 소스 내의 목록을 가져오거나 설정합니다.Gets or sets the list within a data source to monitor.

public:
 property System::String ^ DataMember { System::String ^ get(); void set(System::String ^ value); };
public string DataMember { get; set; }
member this.DataMember : string with get, set
Public Property DataMember As String

속성 값

모니터링할 DataSource에 의해 지정된 데이터 소스 내의 목록을 나타내는 문자열입니다.The string that represents a list within the data source specified by the DataSource to be monitored. 일반적으로, 이것은 DataTable입니다.Typically, this will be a DataTable.

예제

다음 코드 예제를 사용 하는 방법을 보여 줍니다 합니다 ErrorProvider 사용 하 여는 DataSourceDataMember 사용자에 게는 데이터 오류를 나타냅니다.The following code example shows how to use the ErrorProvider with a DataSource and DataMember to indicate a data error to the user.

private:
   void InitializeComponent()
   {
      
      // Standard control setup.
      //....
      // You set the DataSource to a data set, and the DataMember to a table.
      errorProvider1->DataSource = dataSet1;
      errorProvider1->DataMember = dataTable1->TableName;
      errorProvider1->ContainerControl = this;
      errorProvider1->BlinkRate = 200;
      
      //...
      // Since the ErrorProvider control does not have a visible component,
      // it does not need to be added to the form. 
   }


private:
   void buttonSave_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      
      // Checks for a bad post code.
      DataTable^ CustomersTable;
      CustomersTable = dataSet1->Tables[ "Customers" ];
      System::Collections::IEnumerator^ myEnum = (CustomersTable->Rows)->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         DataRow^ row = safe_cast<DataRow^>(myEnum->Current);
         if ( Convert::ToBoolean( row[ "PostalCodeIsNull" ] ) )
         {
            row->RowError = "The Customer details contain errors";
            row->SetColumnError( "PostalCode", "Postal Code required" );
         }
      }
   }
private void InitializeComponent()
 {
     // Standard control setup.
     //....
     // You set the DataSource to a data set, and the DataMember to a table.
     errorProvider1.DataSource = dataSet1 ;
     errorProvider1.DataMember = dataTable1.TableName ;
     errorProvider1.ContainerControl = this ;
     errorProvider1.BlinkRate = 200 ;
     //...
     // Since the ErrorProvider control does not have a visible component,
     // it does not need to be added to the form. 
 }
 
 private void buttonSave_Click(object sender, System.EventArgs e)
 {
     // Checks for a bad post code.
     DataTable CustomersTable;
     CustomersTable = dataSet1.Tables["Customers"];
     foreach (DataRow row in (CustomersTable.Rows)) 
     {
         if (Convert.ToBoolean(row["PostalCodeIsNull"])) 
         {
             row.RowError="The Customer details contain errors";
             row.SetColumnError("PostalCode", "Postal Code required");
         } 
     } 
 }

Private Sub InitializeComponent()
    ' Standard control setup.
    '....                  
    ' You set the DataSource to a data set, and the DataMember to a table.
    errorProvider1.DataSource = dataSet1
    errorProvider1.DataMember = dataTable1.TableName
    errorProvider1.ContainerControl = Me
    errorProvider1.BlinkRate = 200
End Sub
 '...
' Since the ErrorProvider control does not have a visible component,
' it does not need to be added to the form. 

Private Sub buttonSave_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    ' Checks for a bad post code.
    Dim CustomersTable As DataTable
    CustomersTable = dataSet1.Tables("Customers")
    Dim row As DataRow
    For Each row In CustomersTable.Rows
        If Convert.ToBoolean(row("PostalCodeIsNull")) Then
            row.RowError = "The Customer details contain errors"
            row.SetColumnError("PostalCode", "Postal Code required")
        End If
    Next row
End Sub

설명

합니다 DataMember 기반으로 하는 탐색 문자열 DataSource합니다.The DataMember is a navigation string based on DataSource.

런타임에 변경 하는 경우 발생할 수 있는 충돌을 방지 하려면 DataSource 하 고 DataMember를 사용 해야 BindToDataAndErrors 설정 하는 대신 DataSourceDataMember 개별적으로 합니다.To avoid conflicts at run time that can occur when changing DataSource and DataMember, you should use BindToDataAndErrors instead of setting DataSource and DataMember individually.

적용 대상