ToolStripItemCollection.Clear 方法

定義

移除集合的所有項目。Removes all items from the collection.

public:
 virtual void Clear();
public virtual void Clear ();
abstract member Clear : unit -> unit
override this.Clear : unit -> unit
Public Overridable Sub Clear ()

例外狀況

備註

Clear 可以使用方法,從父控制項移除整個控制項集合。Use the Clear method to remove the entire collection of controls from a parent control.

若要從集合中移除個別控制項,請使用 RemoveRemoveAt 方法。To remove an individual control from the collection, use the Remove or RemoveAt method.

若要將新 ToolStripItem 的控制項加入至 ToolStripItemCollection ,請使用 AddAddRange 方法。To add new ToolStripItem controls to the ToolStripItemCollection, use the Add or AddRange method.

給繼承者的注意事項

Clear()在衍生類別中覆寫時,請務必呼叫基類的方法, Clear() 以確保所有控制項都已從集合中移除。When overriding Clear() in a derived class, be sure to call the base class's Clear() method to ensure that all the controls are removed from the collection.

適用於