共用方式為


ApplicationSettingsBase.SettingsSaving 事件

定義

發生於值儲存至資料存放區之前。

public:
 event System::Configuration::SettingsSavingEventHandler ^ SettingsSaving;
public event System.Configuration.SettingsSavingEventHandler SettingsSaving;
member this.SettingsSaving : System.Configuration.SettingsSavingEventHandler 
Public Custom Event SettingsSaving As SettingsSavingEventHandler 

事件類型

範例

下列程式代碼範例顯示 SettingsSavingFormSettings別 物件的事件處理程式,這是衍生自 ApplicationSettingsBase的包裝函式類別。 處理程式會查詢用戶以儲存目前的應用程式設定屬性值。 完整的程式代碼範例會列在類別概觀中 ApplicationSettingsBase

private:
    void FormSettings_SettingsSaving(Object^ sender,
        CancelEventArgs^ e)
    {
        //Should check for settings changes first.
        ::DialogResult^ dialogResult = MessageBox::Show(
            "Save current values for application settings?",
            "Save Settings", MessageBoxButtons::YesNo);
        if (::DialogResult::No == dialogResult)
        {
            e->Cancel = true;
        }
    }
void frmSettings1_SettingsSaving(object sender, CancelEventArgs e)
{
    //Should check for settings changes first.
    DialogResult dr = MessageBox.Show(
                    "Save current values for application settings?",
                    "Save Settings", MessageBoxButtons.YesNo);
    if (DialogResult.No == dr)
    {
        e.Cancel = true;
    }
}
Private Sub frmSettings1_SettingsSaving(ByVal sender As Object, ByVal e As _
        CancelEventArgs) Handles frmSettings1.SettingsSaving
    'Should check for settings changes first.
    Dim dr As DialogResult = MessageBox.Show( _
        "Save current values for application settings?", "Save Settings", _
        MessageBoxButtons.YesNo)
    If (System.Windows.Forms.DialogResult.No = dr) Then
        e.Cancel = True
    End If
End Sub

備註

方法 SettingsSaving 會在將應用程式設定屬性儲存至其相關聯的數據存放區之前,由方法引發 Save 。 相關聯的事件處理程式可以取消此事件。

適用於

另請參閱