windowsforms-devexpress-dot-xtraeditors-dot-xtramessageboxargs-032880ef.md
Gets or sets whether the “Do not show this message again“ checkbox is shown in an XtraMessageBox.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
public bool DoNotShowAgainCheckBoxVisible { get; set; }
Public Property DoNotShowAgainCheckBoxVisible As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | false |
true if the “Do not show this message again“ checkbox is shown in an XtraMessageBox ; otherwise, false.
|
The XtraMessageBox can display the “Do not show this message again“ checkbox.
If a user checks this checkbox and closes the message, the next XtraMessageBox.Show method call that uses the same XtraMessageBoxArgs object does not show a message.
To display the “Do not show this message again“ checkbox, set the XtraMessageBoxArgs.DoNotShowAgainCheckBoxVisible property to true.
private void Custom_EventHandler(object sender, EventArgs e) {
XtraMessageBoxArgs xma = new XtraMessageBoxArgs();
xma.Caption = "XtraMessageBox";
xma.Text = "This is a message.";
xma.DoNotShowAgainCheckBoxVisible = true;
XtraMessageBox.Show(xma);
}
Private Sub Custom_EventHandler(ByVal sender As Object, ByVal e As EventArgs)
Dim xma As New XtraMessageBoxArgs()
xma.Caption = "XtraMessageBox"
xma.Text = "This is a message."
xma.DoNotShowAgainCheckBoxVisible = True
XtraMessageBox.Show(xma)
End Sub
You can use the XtraMessageBoxArgs.DoNotShowAgainCheckBoxText property to change the checkbox’s text.
private void Custom_EventHandler(object sender, EventArgs e) {
XtraMessageBoxArgs xma = new XtraMessageBoxArgs();
// ...
xma.DoNotShowAgainCheckBoxText = "Custom Text";
XtraMessageBox.Show(xma);
}
Private Sub Custom_EventHandler(ByVal sender As Object, ByVal e As EventArgs)
Dim xma As New XtraMessageBoxArgs()
' ...
xma.DoNotShowAgainCheckBoxText = "Custom Text"
XtraMessageBox.Show(xma)
End Sub
The XtraMessageBoxArgs.Load and XtraMessageBoxArgs.Closed events occur when the XtraMessageBox is opened or closed. These events allow you to determine whether a user checked the “Do not show again“ checkbox. Handle these events to read, store, and retrieve the following property values:
| Property | Description |
|---|---|
| XtraMessageBoxEventArgs.Visible | Gets or sets whether an XtraMessageBox is visible. |
| XtraMessageBoxEventArgs.DialogResult | Gets or sets the DialogResult value that corresponds to the button the user chose in an XtraMessageBox. |
You can call the XtraMessageBoxClosedArgs.SaveToRegistry and RestoreFromRegistry() methods to save and load the property values to (from) a registry or store these values in a local variable, a file on local storage, a database, etc.
Subscribe to the XtraMessageBoxArgs.Load and XtraMessageBoxArgs.Closed events. In the Closed event handler, call the SaveToRegistry() method that saves the XtraMessageBoxEventArgs.Visible and XtraMessageBoxEventArgs.DialogResult property values to HKEY_CURRENT_USER\Software\RegistryPath\RegistryKey. The RegistryPath and RegistryKey are specified by the XtraMessageBox.RegistryPath and XtraMessageBoxArgs.RegistryKey properties. If you do not set them, the application generates these parameters automatically:
Path.Combine(Application.CompanyName, Application.ProductName, "Messages")To retrieve the Visible and DialogResult property values, call RestoreFromRegistry().
private void Custom_EventHandler(object sender, EventArgs e) {
XtraMessageBoxArgs xma = new XtraMessageBoxArgs();
// ...
xma.RegistryKey = "ThisIsARegistryKey";
xma.RegistryPath = "ThisIsARegistryPath";
xma.Load += Xma_Load;
xma.Closed += Xma_Closed;
XtraMessageBox.Show(xma);
}
private void Xma_Load(object sender, XtraMessageBoxLoadArgs e) {
e.RestoreFromRegistry();
if(e.DialogResult == DialogResult.OK) {
// Apply custom settings.
}
else if(e.DialogResult == DialogResult.Cancel) {
// Apply custom settings.
}
}
private void Xma_Closed(object sender, XtraMessageBoxClosedArgs e) {
e.SaveToRegistry();
if(e.DialogResult == DialogResult.OK) {
// Apply custom settings.
}
else if(e.DialogResult == DialogResult.Cancel) {
// Apply custom settings.
}
}
Private Sub Custom_EventHandler(ByVal sender As Object, ByVal e As EventArgs)
Dim xma As New XtraMessageBoxArgs()
' ...
xma.RegistryKey = "ThisIsARegistryKey"
xma.RegistryPath = "ThisIsARegistryPath"
AddHandler xma.Load, AddressOf Xma_Load
AddHandler xma.Closed, AddressOf Xma_Closed
XtraMessageBox.Show(xma)
End Sub
Private Sub Xma_Load(ByVal sender As Object, ByVal e As XtraMessageBoxLoadArgs)
e.RestoreFromRegistry()
If e.DialogResult = DialogResult.OK Then
' Apply custom settings.
ElseIf e.DialogResult = DialogResult.Cancel Then
' Apply custom settings.
End If
End Sub
Private Sub Xma_Closed(ByVal sender As Object, ByVal e As XtraMessageBoxClosedArgs)
e.SaveToRegistry()
If e.DialogResult = DialogResult.OK Then
' Apply custom settings.
ElseIf e.DialogResult = DialogResult.Cancel Then
' Apply custom settings.
End If
End Sub
In this example the XtraMessageBoxEventArgs.Visible and XtraMessageBoxEventArgs.DialogResult property values are stored in a text file on the local storage.
private void Form1_DoubleClick(object sender, EventArgs e) {
XtraMessageBoxArgs xma = new XtraMessageBoxArgs();
// ...
xma.Load += Xma_Load;
xma.Closed += Xma_Closed;
XtraMessageBox.Show(xma);
}
private void Xma_Load(object sender, XtraMessageBoxLoadArgs e) {
string messageDisplayed = System.IO.File.ReadAllText(@"C:\Users\Public\Documents\Settings.txt");
string dialogResult = System.IO.File.ReadAllText(@"C:\Users\Public\Documents\DialogResult.txt");
if(Convert.ToBoolean(messageDisplayed) == true) {
e.Visible = true;
}
if(button == DialogResult.OK) {
// Apply custom settings.
}
else if(button == DialogResult.Cancel) {
// Apply custom settings.
}
}
private void Xma_Closed(object sender, XtraMessageBoxClosedArgs e) {
bool messageDisplayed = e.Visible;
DialogResult dialogResult = e.DialogResult;
System.IO.File.WriteAllText(@"C:\Users\Public\Documents\Settings.txt", messageDisplayed.ToString());
System.IO.File.WriteAllText(@"C:\Users\Public\Documents\DialogResult.txt", dialogResult.ToString());
if(e.DialogResult == DialogResult.OK) {
// Apply custom settings.
}
else if(e.DialogResult == DialogResult.Cancel) {
// Apply custom settings.
}
}
Private Sub Form1_DoubleClick(ByVal sender As Object, ByVal e As EventArgs)
Dim xma As New XtraMessageBoxArgs()
' ...
AddHandler xma.Load, AddressOf Xma_Load
AddHandler xma.Closed, AddressOf Xma_Closed
XtraMessageBox.Show(xma)
End Sub
Private Sub Xma_Load(ByVal sender As Object, ByVal e As XtraMessageBoxLoadArgs)
Dim messageDisplayed As String = System.IO.File.ReadAllText("C:\Users\Public\Documents\Settings.txt")
Dim dialogResult As String = System.IO.File.ReadAllText("C:\Users\Public\Documents\DialogResult.txt")
If Convert.ToBoolean(messageDisplayed) = True Then
e.Visible = True
End If
If button = DialogResult.OK Then
' Apply custom settings.
ElseIf button = DialogResult.Cancel Then
' Apply custom settings.
End If
End Sub
Private Sub Xma_Closed(ByVal sender As Object, ByVal e As XtraMessageBoxClosedArgs)
Dim messageDisplayed As Boolean = e.Visible
Dim dialogResult As DialogResult = e.DialogResult
System.IO.File.WriteAllText("C:\Users\Public\Documents\Settings.txt", messageDisplayed.ToString())
System.IO.File.WriteAllText("C:\Users\Public\Documents\DialogResult.txt", dialogResult.ToString())
If e.DialogResult = DialogResult.OK Then
' Apply custom settings.
ElseIf e.DialogResult = DialogResult.Cancel Then
' Apply custom settings.
End If
End Sub
If you need to show an XtraMessageBox a user suppressed, call the ShowMessage(Boolean) method in the XtraMessageBoxArgs.Load event handler. The XtraMessageBox opens with the checkbox unchecked. If you need to forcibly show an XtraMessageBox with the checkbox checked, pass true to the ShowMessage() method.
private void Xma_Load(object sender, XtraMessageBoxLoadArgs e) {
e.RestoreFromRegistry();
if(e.Visible == false /* && SecondCondition*/ ) {
e.ShowMessage();
}
Private Sub Xma_Load(ByVal sender As Object, ByVal e As XtraMessageBoxLoadArgs)
e.RestoreFromRegistry()
If e.Visible = False 'AndAlso SecondCondition
Then
e.ShowMessage()
End If
See Also