DataGridColumnStyle.CheckValidDataSource(CurrencyManager) 方法

定义

如果 DataGrid 没有有效数据源,或该列未映射到数据源中的有效属性,将引发异常。

protected:
 void CheckValidDataSource(System::Windows::Forms::CurrencyManager ^ value);
protected void CheckValidDataSource (System.Windows.Forms.CurrencyManager value);
member this.CheckValidDataSource : System.Windows.Forms.CurrencyManager -> unit
Protected Sub CheckValidDataSource (value As CurrencyManager)

参数

value
CurrencyManager

要检查的 CurrencyManager

例外

valuenull

示例

下面的代码示例获取数据源的一个 CurrencyManager 值,并使用该 CheckValidDataSource 示例来确定该数据源是否 CurrencyManager 有效。

private:
   void CheckCurrencyManager( CurrencyManager^ myCurrencyManager )
   {
      // This code is from a class named MyDataGridColumnStyle derived
      // from DataGridColumnStyle.
      MyDataGridColumnStyle^ myGridColumn = this;
      try
      {
         myGridColumn->CheckValidDataSource( myCurrencyManager );
      }
      catch ( ArgumentNullException^ e ) 
      {
         Console::WriteLine( e->Message );
      }
      catch ( ApplicationException^ e ) 
      {
         Console::WriteLine( e->Message );
      }
   }
private void CheckCurrencyManager(CurrencyManager myCurrencyManager) {
    // This code is from a class named MyDataGridColumnStyle derived
    // from DataGridColumnStyle.
    MyDataGridColumnStyle myGridColumn = this;
    try {
        myGridColumn.CheckValidDataSource(myCurrencyManager);
    }
    catch (ArgumentNullException e) {
        Console.WriteLine(e.Message);
    }
    catch (ApplicationException e) {
        Console.WriteLine(e.Message);
    }
}
Private Sub CheckCurrencyManager(myCurrencyManager As CurrencyManager)
    ' This code is from a class named MyDataGridColumnStyle derived
    ' from DataGridColumnStyle.
    Dim myGridColumn As MyDataGridColumnStyle = Me
    Try
        myGridColumn.CheckValidDataSource(myCurrencyManager)
    Catch e As ArgumentNullException
        Console.WriteLine(e.Message)
    Catch e As ApplicationException
        Console.WriteLine(e.Message)
    End Try
End Sub

适用于