Message Box in C#
Results 1 to 3 of 3

Thread: Message Box in C#

  1. #1
    Junior Member Xarzu's Avatar
    Join Date
    Jan 2008
    Posts
    13

    Message Box in C#

    What is a good way to code a messagebox in C#, like the AfxMessageBox in used in Visal C++?

    For code like the following, there must be a "using..."
    declaration missing because I got this error:
    error CS0246: The type or namespace name 'MessageBoxButtons' could not be found (are you missing a using directive or an assembly reference?)

    Code:
    string message = "blah";
    string caption = "blah";
    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
    DialogResult result;
    
    result = MessageBox.Show(message, caption, buttons, icon);



    Also, is there a good way to write information out to a log file?

  2. #2
    Banned
    Join Date
    Aug 2001
    Location
    Yes
    Posts
    4,429
    Try "using System.Windows.Forms"

  3. #3
    Custom User
    Join Date
    Oct 2001
    Posts
    503
    If you're using Visual Studio classes/structures that have the correct namespace imported show up as light blue whereas ones that don't show up as normal text. An easy way to add the correct using statement (assuming the assembly containing the class is references - which System.Windows.Forms will be normally) you can put the cursor at the far right side of the name and a small red rectangle will show up. Put your mouse over this rectangle and a box will appear. Click the box and a menu shows up asking if you want to add the using statement.

    ac

Similar Threads

  1. Windows Error Messages
    By cheyenne1212 in forum Miscellaneous Security Discussions
    Replies: 7
    Last Post: February 1st, 2012, 01:51 PM
  2. Port List
    By ThePreacher in forum Miscellaneous Security Discussions
    Replies: 17
    Last Post: December 14th, 2006, 08:37 PM
  3. problem installing Windows...
    By AsCenDinG in forum Microsoft Security Discussions
    Replies: 21
    Last Post: July 24th, 2004, 04:04 PM
  4. How to read email header
    By rajat in forum Roll Call
    Replies: 0
    Last Post: February 20th, 2002, 04:08 AM
  5. Traceroute: under the hood
    By antihaxor in forum Non-Security Archives
    Replies: 0
    Last Post: January 24th, 2002, 04:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides