語言

DataGridDesigner.Initialize(IComponent) 方法

定義

初始化設計者並使用指定的 DataGrid 控制項。

public:
 override void Initialize(System::ComponentModel::IComponent ^ component);
public override void Initialize(System.ComponentModel.IComponent component);
override this.Initialize : System.ComponentModel.IComponent -> unit
Public Overrides Sub Initialize (component As IComponent)

參數

component
IComponent

控制元件正在設計中。

範例

以下程式碼範例說明如何覆寫該 Initialize 方法,確保設計者僅以類別的 SimpleDataGrid 實例初始化。

此程式碼範例是本類別更大範例 DataGridDesigner 的一部分。

' Override the Initialize method to ensure that
' only an instance of the SimpleDataList class is
' used by this designer class.
Public Overrides Sub Initialize(ByVal component As IComponent)
    simpleList = CType(component, SimpleDataList)

    If IsNothing(simpleList) Then
        Throw New ArgumentException("Must be a SimpleDataList.", "component")
    End If

    MyBase.Initialize(component)
End Sub

適用於

另請參閱