Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 寻找如何制作我自己的MessageBox示例代码_C#_.net_Winforms_Messagebox - Fatal编程技术网

C# 寻找如何制作我自己的MessageBox示例代码

C# 寻找如何制作我自己的MessageBox示例代码,c#,.net,winforms,messagebox,C#,.net,Winforms,Messagebox,寻找如何制作我自己的MessageBox示例代码 简单的东西,有标题,正文和是/否按钮 如何使用它 提前感谢您可以创建自定义对话框,如下所示: 您可以创建自定义对话框,如下所示: 对此有一个明确的定义。它会自动在屏幕上显示一个带有您指定参数的消息框。例如,以下代码行: MessageBox.Show("Your body text goes here.", "Message Title", MessageBoxButtons.Yes

寻找如何制作我自己的MessageBox示例代码

简单的东西,有标题,正文和是/否按钮

如何使用它


提前感谢

您可以创建自定义对话框,如下所示:


您可以创建自定义对话框,如下所示:

对此有一个明确的定义。它会自动在屏幕上显示一个带有您指定参数的消息框。例如,以下代码行:

MessageBox.Show("Your body text goes here.",
                "Message Title",
                MessageBoxButtons.YesNo);
将生成一个如下所示的消息框:


您还可以使用的为消息框指定图标。例如:

MessageBox.Show("Your body text goes here.",
                "Message Title",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning);
private void QueryExitApplication()
{
    // Show a message box, asking the user to confirm that they want to quit
    DialogResult result;
    result = MessageBox.Show("Do you really want to quit this application?",
                             "Quit Application?",
                             MessageBoxButtons.YesNo,
                             MessageBoxIcon.Warning);

    // Check the returned value of the MessageBox.Show function
    // (this corresponds to the button clicked by the user)
    if (result == DialogResult.Yes)
    {
        // Close the form
        this.Close();
    }

    // Otherwise, they selected No (so do nothing)
}
图标值的完整列表可用


MessageBox.Show
函数的返回值对应于在消息框上单击的按钮。通过检查返回值,您可以确定用户选择了哪个操作过程。例如:

MessageBox.Show("Your body text goes here.",
                "Message Title",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning);
private void QueryExitApplication()
{
    // Show a message box, asking the user to confirm that they want to quit
    DialogResult result;
    result = MessageBox.Show("Do you really want to quit this application?",
                             "Quit Application?",
                             MessageBoxButtons.YesNo,
                             MessageBoxIcon.Warning);

    // Check the returned value of the MessageBox.Show function
    // (this corresponds to the button clicked by the user)
    if (result == DialogResult.Yes)
    {
        // Close the form
        this.Close();
    }

    // Otherwise, they selected No (so do nothing)
}
这是有道理的。它会自动在屏幕上显示一个带有您指定参数的消息框。例如,以下代码行:

MessageBox.Show("Your body text goes here.",
                "Message Title",
                MessageBoxButtons.YesNo);
将生成一个如下所示的消息框:


您还可以使用的为消息框指定图标。例如:

MessageBox.Show("Your body text goes here.",
                "Message Title",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning);
private void QueryExitApplication()
{
    // Show a message box, asking the user to confirm that they want to quit
    DialogResult result;
    result = MessageBox.Show("Do you really want to quit this application?",
                             "Quit Application?",
                             MessageBoxButtons.YesNo,
                             MessageBoxIcon.Warning);

    // Check the returned value of the MessageBox.Show function
    // (this corresponds to the button clicked by the user)
    if (result == DialogResult.Yes)
    {
        // Close the form
        this.Close();
    }

    // Otherwise, they selected No (so do nothing)
}
图标值的完整列表可用


MessageBox.Show
函数的返回值对应于在消息框上单击的按钮。通过检查返回值,您可以确定用户选择了哪个操作过程。例如:

MessageBox.Show("Your body text goes here.",
                "Message Title",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning);
private void QueryExitApplication()
{
    // Show a message box, asking the user to confirm that they want to quit
    DialogResult result;
    result = MessageBox.Show("Do you really want to quit this application?",
                             "Quit Application?",
                             MessageBoxButtons.YesNo,
                             MessageBoxIcon.Warning);

    // Check the returned value of the MessageBox.Show function
    // (this corresponds to the button clicked by the user)
    if (result == DialogResult.Yes)
    {
        // Close the form
        this.Close();
    }

    // Otherwise, they selected No (so do nothing)
}

呃,你为什么想要一个看起来很难看的留言盒?你可以使用内置的。它是免费的。你不必做更糟糕的工作来重塑你自己。如果你想使用这个内置的,你可以在这里找到一些细节,呃,为什么你会想要一个看起来很可怕的消息框呢?你可以使用内置的。它是免费的。你不必做更糟糕的工作来重塑你自己。如果你想使用构建的,你可以在这里找到一些细节