ISupportInitialize 介面

定義

指定這個物件對批次初始設定支援簡單的異動通知。

C#
public interface ISupportInitialize
衍生

範例

下列程式代碼範例示範如何使用 ISupportInitialize 介面來初始化三 TrackBar 個控件。

C#
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar3)).BeginInit();
this.SuspendLayout();
// 
// trackBar1
// 
this.trackBar1.Location = new System.Drawing.Point(160, 400);
this.trackBar1.Name = "trackBar1";
this.trackBar1.TabIndex = 1;
this.trackBar1.Scroll += new System.EventHandler(this.trackBar_Scroll);
// 
// trackBar2
// 
this.trackBar2.Location = new System.Drawing.Point(608, 40);
this.trackBar2.Name = "trackBar2";
this.trackBar2.TabIndex = 2;
this.trackBar2.Scroll += new System.EventHandler(this.trackBar_Scroll);
// 
// trackBar3
// 
this.trackBar3.Location = new System.Drawing.Point(56, 40);
this.trackBar3.Name = "trackBar3";
this.trackBar3.TabIndex = 3;
this.trackBar3.Scroll += new System.EventHandler(this.trackBar_Scroll);
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar3)).EndInit();

備註

ISupportInitialize 允許控件優化多個屬性指派。 因此,您可以在設計時間初始化共同相依屬性或批次設定多個屬性。

BeginInit呼叫 方法,以向對象發出初始化開始的訊號。 EndInit呼叫 方法以發出初始化完成的訊號。

方法

BeginInit()

表示物件正在啟動初始設定。

EndInit()

表示物件已完成初始設定。

適用於

產品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

另請參閱