Search code examples
c#visual-studio-2008compact-frameworkmessageboxdialogresult

C# MessageBox with DialogResult giving "No overload for method 'Show' takes '3' arguments"


I am developing an application for Windows CE using Visual Studio 2008.

Code:

    private void cmdLogOn_Click(object sender, EventArgs e)
      {
        if (loginStatus == false)
        {
            DialogResult dialogresult = MessageBox.Show("Are you sure?", "text", MessageBoxButtons.YesNo);
            if (dialogresult == DialogResult.Yes)
            {
                //Do Stuff;
            }
        }
        else
        {
            //Do stuff
        }
    }

I am getting the error : "No overload for method 'Show' takes '3' arguments". Any idea why?

EDIT: Here is a step by step using a new application to demonstrate the issue:

  1. As you can see, I am using VS2008

enter image description here

2.Visual C# > Smart Device Project

enter image description here

  1. Target platform: Windows CE - .NET Compact Framework Version 3.5

enter image description here

  1. I create a button = button1 & a label = label1

enter image description here

  1. Here is the code I entered, but the error persists

enter image description here


Solution

  • The simple answer is in the .NET Compact framework there is no overload which takes 3 arguments, as the error says.

    You can use this:

    DialogResult dialogresult = MessageBox.Show("Are you sure?", "text",
        MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);