HeaderPane
Main
Hide
Share Link
Print

SftMessageBox Class

Displays a message box in light mode, dark mode or with the colors of the Windows contrast theme.

SftMessageBox has the methods of the Windows Forms MessageBox class and takes the same arguments, so replacing the class name is all an application changes. Without an owner, the message box appears in front of the active form. It uses the mode of the application's SftStyle component, which every application that uses SftStyle/NET has and which carries the license the message box needs; it takes the mode when it opens.

MessageBoxButtons.CancelTryContinue and the results DialogResult.TryAgain and DialogResult.Continue exist in .NET 10 and later only; on .NET Framework the message box accepts the value 6 for the buttons and returns 10 and 11 for them.

With MessageBoxOptions.DefaultDesktopOnly or MessageBoxOptions.ServiceNotification the Windows message box is shown instead, since such a message box appears on a desktop the application's windows are not on; the owner and the Help button are then left out.

Namespace: Softelvdm.SftStyleNET
Assembly: Softelvdm.SftStyleNET

Inheritance

Syntax

public static class SftMessageBox;
Public NotInheritable Class SftMessageBox

Constructors

This class cannot be instantiated.

Methods

PublicStaticShowDisplays a message box with the specified text.

Examples

C# View entire sample code

        private void sliderPrice_RangeChanged(object sender, EventArgs e) {
            ShowSliders();
        }

        private void ShowSliders() {
            labelSliders.Text = "Volume " + sliderVolume.Value + ", price range " + sliderPrice.LowerValue + " to " + sliderPrice.UpperValue;
        }

        // SftMessageBox takes the arguments of MessageBox.Show and returns the same results.
        private void buttonMessageBox_Click(object sender, EventArgs e) {
            DialogResult result = SftMessageBox.Show(this, "Do you want to save the changes to Order 1042 before closing?", "Orders",
                MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            labelResult.Text = "Message box: " + result;
        }

        private void buttonTaskDialog_Click(object sender, EventArgs e) {

VB.NET View entire sample code

    Private Sub SliderPrice_RangeChanged(ByVal sender As Object, ByVal e As EventArgs) Handles SliderPrice.RangeChanged
        ShowSliders()
    End Sub

    Private Sub ShowSliders()
        LabelSliders.Text = "Volume " + SliderVolume.Value.ToString() + ", price range " + SliderPrice.LowerValue.ToString() + " to " + SliderPrice.UpperValue.ToString()
    End Sub

    ' SftMessageBox takes the arguments of MessageBox.Show and returns the same results.
    Private Sub ButtonMessageBox_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonMessageBox.Click
        Dim result As DialogResult = SftMessageBox.Show(Me, "Do you want to save the changes to Order 1042 before closing?", "Orders",
            MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
        LabelResult.Text = "Message box: " + result.ToString()
    End Sub

    Private Sub ButtonTaskDialog_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonTaskDialog.Click

See Also Classes | SftStyle/NET 3.0