2

How can I add message to popup text box:

        catch (Exception)
        {
            Interaction.MsgBox(Conversion.ErrorToString(), MsgBoxStyle.Critical, null);
        }
3
  • Did you come over to C# from VB6? Ditch that Microsoft.VisualBasic namespace, its trash :) Commented Jun 3, 2011 at 19:35
  • 1
    please be sure to come back and choose the most helpful answer by clicking on the big checkmark next to it. Commented Jun 3, 2011 at 19:35
  • @Allen I have, I must say I tend to agree Commented Jun 3, 2011 at 19:37

4 Answers 4

4

You can use the MessageBox class.

catch (Exception)
{
    MessageBox.Show(
         Conversion.ErrorToString(),  // Caption
         "Error:",                    // Title displayed
         MessageBoxButtons.OK,        // Only show OK button
         MessageBoxIcon.Error);       // Show error icon (similar to Critical)
}
Sign up to request clarification or add additional context in comments.

Comments

2
MessageBox.Show("text", "caption", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);

Also, I see you tagged the post C#. If you're using C#, don't use anything in the Microsoft.VisualBasic namespace (which is where Interaction lives)

The Microsoft.VisualBasic namespace contains types that support the Visual Basic Runtime in Visual Basic.

Comments

0

Some more examples:

http://www.dotnetperls.com/messagebox-show

Comments

0

You already are, with Conversion.ErrorToString(). If you want a custom message, just pass a string of your choosing as the first argument instead. The third argument (which you have null), can be used to pass a string for the title if you want.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.