Share via


ExceptionMessageBox.CheckBoxRegistryKey Propriedade

Definição

Define uma abertura RegistryKey que controla a caixa de seleção que é exibida na caixa de mensagem de exceção quando ShowCheckBox é true.

public:
 property Microsoft::Win32::RegistryKey ^ CheckBoxRegistryKey { Microsoft::Win32::RegistryKey ^ get(); void set(Microsoft::Win32::RegistryKey ^ value); };
public Microsoft.Win32.RegistryKey CheckBoxRegistryKey { get; set; }
member this.CheckBoxRegistryKey : Microsoft.Win32.RegistryKey with get, set
Public Property CheckBoxRegistryKey As RegistryKey

Valor da propriedade

RegistryKey que controla a caixa de seleção exibida na caixa de mensagem de exceção quando ShowCheckBox é true.

Exemplos

try
{
    // Do something that could generate an exception.
    throw new ApplicationException("An error has occured.");
}
catch (ApplicationException ex)
{
    string str = "The action failed. Do you want to continue?";
    ApplicationException exTop = new ApplicationException(str, ex);
    exTop.Source = this.Text;

    // Show a message box with Yes and No buttons
    ExceptionMessageBox box = new ExceptionMessageBox(exTop,
        ExceptionMessageBoxButtons.YesNo,
        ExceptionMessageBoxSymbol.Question,
        ExceptionMessageBoxDefaultButton.Button2);

    // Enable the check box.
    box.ShowCheckBox = true;

    // Define the registry key to use.
    box.CheckBoxRegistryKey =
        Microsoft.Win32.Registry.CurrentUser.CreateSubKey(
        @"Software\TestApp");
    box.CheckBoxRegistryValue = "DontShowActionFailedMessage";
    box.CheckBoxRegistryMeansDoNotShowDialog = true;
    box.DefaultDialogResult = DialogResult.Yes;

    // The message box won't be displayed if the
    // "DontShowActionFailedMessage" value of the registry key 
    // contains a non-zero value.
    if (box.Show(this) == DialogResult.No)
    {
        // Do something if the user clicks the No button.
        this.Close();
    }
}
Try
    ' Do something that could generate an exception.
    Throw New ApplicationException("An error has occured.")
Catch ex As ApplicationException
    Dim str As String = "The action failed. Do you want to continue?"
    Dim exTop As ApplicationException = New ApplicationException(str, ex)
    exTop.Source = Me.Text

    ' Show a message box with Yes and No buttons
    Dim box As ExceptionMessageBox = New ExceptionMessageBox(exTop, _
     ExceptionMessageBoxButtons.YesNo, _
     ExceptionMessageBoxSymbol.Question, _
     ExceptionMessageBoxDefaultButton.Button2)

    ' Enable the check box.
    box.ShowCheckBox = True

    ' Define the registry key to use.
    box.CheckBoxRegistryKey = _
    Microsoft.Win32.Registry.CurrentUser.CreateSubKey( _
     "Software\TestApp")
    box.CheckBoxRegistryValue = "DontShowActionFailedMessage"
    box.CheckBoxRegistryMeansDoNotShowDialog = True
    box.DefaultDialogResult = Windows.Forms.DialogResult.Yes

    ' The message box won't be displayed if the
    ' "DontShowActionFailedMessage" value of the registry key 
    ' contains a non-zero value.
    If box.Show(Me) = Windows.Forms.DialogResult.No Then
        ' Do something if the user clicks the No button.
        Me.Close()
    End If
End Try

Comentários

Essa propriedade é usada CheckBoxRegistryValue para inicializar o estado selecionado da caixa de seleção. Se o valor do Registro especificado existir e contiver um valor não zero, a caixa de seleção será exibida como selecionada; caso contrário, a caixa de seleção é exibida como clara. Se CheckBoxRegistryMeansDoNotShowDialog for true e o valor do Registro existir e contiver um valor não zero, a caixa de mensagem não será exibida e ExceptionMessageBox retornará DefaultDialogResult quando Show for chamada.

O RegistryKey aplicativo deve ser aberto antes da chamada Show.

Aplica-se a