IPersistComponentSettings.SaveSettings 属性

定义

获取或设置一个值,该值指示控件是否应自动保持其应用程序设置属性。Gets or sets a value indicating whether the control should automatically persist its application settings properties.

public:
 property bool SaveSettings { bool get(); void set(bool value); };
public bool SaveSettings { get; set; }
member this.SaveSettings : bool with get, set
Public Property SaveSettings As Boolean

属性值

如果控件应自动保持其状态,则为 true;否则为 falsetrue if the control should automatically persist its state; otherwise, false.

示例

下面的代码示例演示了在尝试自动保留其配置数据之前,控件检查 SaveSettings 属性的值的正确方法。The following code example shows the proper way for a control to check the value of the SaveSettings property before it attempts to automatically persist its configuration data.

protected override void Dispose( bool disposing ) {

if(disposing) {

try {

if (SaveSettings) {

SaveComponentSettings();

}

}

finally {

//...

}

}

注解

如果控件包含配置数据,通常会保留此数据,以响应对 SaveComponentSettings 方法的显式调用,或有时在调用控件的 Dispose 方法时隐式调用。If a control contains configuration data, it will typically persist this data in response to an explicit call to the SaveComponentSettings method or sometimes implicitly when the control's Dispose method is invoked. SaveSettings 属性确定控件在释放时是否自动保存其配置数据。The SaveSettings property determines whether a control automatically persists its configuration data when it is disposed.

SaveSettings 的默认值取决于控件的实现。The default value of SaveSettings depends on the implementation of the control. 控件的文档应指示它是使用应用程序设置、保留哪些数据以及 SaveSettings 属性的默认值。The documentation for the control should indicate whether it uses application settings, what data is persisted, and what the default value of the SaveSettings property is.

适用于

另请参阅