次の方法で共有


SettingsSavedEventArgs.FailedSettingsList プロパティ

定義

ClientSettingsProvider がサーバーに保存できなかった設定を取得します。

public:
 property System::Collections::ObjectModel::ReadOnlyCollection<System::String ^> ^ FailedSettingsList { System::Collections::ObjectModel::ReadOnlyCollection<System::String ^> ^ get(); };
public System.Collections.ObjectModel.ReadOnlyCollection<string> FailedSettingsList { get; }
member this.FailedSettingsList : System.Collections.ObjectModel.ReadOnlyCollection<string>
Public ReadOnly Property FailedSettingsList As ReadOnlyCollection(Of String)

プロパティ値

保存されなかった設定。

次のコード例は、このプロパティを使用して、正常に保存されなかった設定の一覧を表示する方法を示しています。

private void AttachSettingsSavedEventHandler()
{
    ((ClientSettingsProvider)Properties.Settings.Default.Providers
        ["System.Web.ClientServices.Providers.ClientSettingsProvider"])
        .SettingsSaved +=
        new EventHandler<SettingsSavedEventArgs>(Form1_SettingsSaved);
}

private void Form1_SettingsSaved(object sender,
    SettingsSavedEventArgs e)
{
    // If any settings were not saved, display a list of them.
    if (e.FailedSettingsList.Count > 0)
    {
        String failedSettings = String.Join(
            Environment.NewLine,
            e.FailedSettingsList.ToArray());

        String message = String.Format("{0}{1}{1}{2}",
            "The following setting(s) were not saved:",
            Environment.NewLine, failedSettings);

        MessageBox.Show(message, "Unable to save settings",
            MessageBoxButtons.OK, MessageBoxIcon.Warning);
    }
}
Private WithEvents settingsProvider As ClientSettingsProvider = My.Settings _
    .Providers("System.Web.ClientServices.Providers.ClientSettingsProvider")

Private Sub Form1_SettingsSaved(ByVal sender As Object, _
    ByVal e As SettingsSavedEventArgs) _
    Handles settingsProvider.SettingsSaved

    ' If any settings were not saved, display a list of them.
    If e.FailedSettingsList.Count > 0 Then

        Dim failedSettings As String = String.Join( _
            Environment.NewLine, e.FailedSettingsList.ToArray())

        Dim message As String = String.Format("{0}{1}{1}{2}", _
            "The following setting(s) were not saved:", _
            Environment.NewLine, failedSettings)

        MessageBox.Show(message, "Unable to save settings", _
            MessageBoxButtons.OK, MessageBoxIcon.Warning)

    End If

End Sub

注釈

プロバイダーが設定の保存に失敗する理由の 1 つは、現在のユーザーがログアウトしている場合です。プロパティを FailedSettingsList 使用して、設定が正常に保存されなかったかどうかを判断できます。

適用対象

こちらもご覧ください