消息框传递选择C# [英] Message box pass selection C#

查看:71
本文介绍了消息框传递选择C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试检查课本是空的。如果是,请向用户显示是,否的消息框,并取消询问是否选择默认代码。如果用户舔是,请将邮政编码传递到文本框。



我尝试过:



Trying to check textbook is empty. If so, show the user a message box with Yes, No and cancel asking if to chose default code. If user lick yes, pass zip code to the text box.

What I have tried:

private void Submit_Click(object sender, EventArgs e)
{

    if (PostalCodeTextBox.Text == "")
    {

        DialogResult result1 = MessageBox.Show("Please Enter zip code, or chose yes to select default zip code", MessageBoxButtons.YesNoCancel); 
    }
    else
    {
        PostalCodeTextBox.Text = "44844";
    }

推荐答案

Sooo ......问题是......?



看起来你没有检查那个DialogResult的值,所以在将任何内容放入TextBox之前你可能想要这样做。
Sooo... the question would be ....?

It looks like you're not checking the value of that DialogResult so you might want to do that before putting anything in the TextBox.


这篇关于消息框传递选择C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆