ErrorProvider.DataSource プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ErrorProvider.DataSource プロパティの意味・解説 

ErrorProvider.DataSource プロパティ

ErrorProvider が監視するデータ ソース取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim instance As ErrorProvider
Dim value As Object

value = instance.DataSource

instance.DataSource = value
public Object DataSource { get; set;
 }
/** @property */
public Object get_DataSource ()

/** @property */
public void set_DataSource (Object value)

プロパティ
IList インターフェイスに基づく、エラー監視させるためのデータ ソース通常、これはエラー監視させるための DataSet です。

解説解説

DataSource は、コントロール結び付けたりエラー監視したりするデータ ソースです。DataSource は、IList実装する任意のコレクション設定できます

DataSource と DataMember を変更しても、実行時競合発生しないようにするには、DataSourceDataMember個別設定するではなく、BindToDataAndErrors を使用する必要があります

使用例使用例

DataSource および DataMember併せて ErrorProvider使用しデータ エラーユーザー提示するコード例次に示します

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 'InitializeComponent
 '...
' 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 = customersDataSet1.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 'buttonSave_Click
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 = customersDataSet1.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:
   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 = customersDataSet1->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.set_DataSource(dataSet1);
    errorProvider1.set_DataMember(dataTable1.get_TableName());
    errorProvider1.set_ContainerControl(this);
    errorProvider1.set_BlinkRate(200);
    //...
    // Since the ErrorProvider control does not have a visible component
,
    // it does not need to be added to the form. 
} //InitializeComponent

protected void buttonSave_Click(Object sender,
 System.EventArgs e)
{
    // Checks for a bad post code.
    DataTable customersTable;
    customersTable = customersDataSet1.get_Tables().get_Item("Customers");
    for (int iCtr = 0; iCtr < customersTable.get_Rows().get_Count();
 
         iCtr++) {
        DataRow row = customersTable.get_Rows().get_Item(iCtr);
        if (Convert.ToBoolean(row.get_Item("PostalCodeIsNull")))
 {
            row.set_RowError("The Customer details contain errors");
            row.SetColumnError("PostalCode", "Postal Code required");
        }
    }
} //buttonSave_Click
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ErrorProvider クラス
ErrorProvider メンバ
System.Windows.Forms 名前空間
ErrorProvider.DataMember プロパティ
IList


このページでは「.NET Framework クラス ライブラリ リファレンス」からErrorProvider.DataSource プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からErrorProvider.DataSource プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からErrorProvider.DataSource プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ErrorProvider.DataSource プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ErrorProvider.DataSource プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS