<i id='i38YS'><tr id='i38YS'><dt id='i38YS'><q id='i38YS'><span id='i38YS'><b id='i38YS'><form id='i38YS'><ins id='i38YS'></ins><ul id='i38YS'></ul><sub id='i38YS'></sub></form><legend id='i38YS'></legend><bdo id='i38YS'><pre id='i38YS'><center id='i38YS'></center></pre></bdo></b><th id='i38YS'></th></span></q></dt></tr></i><div id='i38YS'><tfoot id='i38YS'></tfoot><dl id='i38YS'><fieldset id='i38YS'></fieldset></dl></div>

    • <bdo id='i38YS'></bdo><ul id='i38YS'></ul>
  1. <tfoot id='i38YS'></tfoot>
  2. <legend id='i38YS'><style id='i38YS'><dir id='i38YS'><q id='i38YS'></q></dir></style></legend>

      <small id='i38YS'></small><noframes id='i38YS'>

      创建返回值的自定义对话框的最简单方法是什么?

      时间:2023-09-14

        <legend id='Cjruv'><style id='Cjruv'><dir id='Cjruv'><q id='Cjruv'></q></dir></style></legend>

          <tbody id='Cjruv'></tbody>
            <tfoot id='Cjruv'></tfoot>
              <bdo id='Cjruv'></bdo><ul id='Cjruv'></ul>
              <i id='Cjruv'><tr id='Cjruv'><dt id='Cjruv'><q id='Cjruv'><span id='Cjruv'><b id='Cjruv'><form id='Cjruv'><ins id='Cjruv'></ins><ul id='Cjruv'></ul><sub id='Cjruv'></sub></form><legend id='Cjruv'></legend><bdo id='Cjruv'><pre id='Cjruv'><center id='Cjruv'></center></pre></bdo></b><th id='Cjruv'></th></span></q></dt></tr></i><div id='Cjruv'><tfoot id='Cjruv'></tfoot><dl id='Cjruv'><fieldset id='Cjruv'></fieldset></dl></div>

                <small id='Cjruv'></small><noframes id='Cjruv'>

              1. 本文介绍了创建返回值的自定义对话框的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想为我的 C# 项目创建一个自定义对话框.我想在这个自定义对话框中有一个DataGridView,而且还会有一个按钮.当用户单击该按钮时,将向调用者返回一个整数值,然后对话框自行终止.

                I want to create a custom dialog box for my C# project. I want to have a DataGridView in this custom dialog box, and there will also be a button. When the user clicks this button, an integer value is returned to the caller, and the dialog box then terminates itself.

                我怎样才能做到这一点?

                How can I achieve this?

                推荐答案

                C#中没有提示对话框.您可以创建一个自定义提示框来代替.

                There is no prompt dialog box in C#. You can create a custom prompt box to do this instead.

                  public static class Prompt
                    {
                        public static int ShowDialog(string text, string caption)
                        {
                            Form prompt = new Form();
                            prompt.Width = 500;
                            prompt.Height = 100;
                            prompt.Text = caption;
                            Label textLabel = new Label() { Left = 50, Top=20, Text=text };
                            NumericUpDown inputBox = new NumericUpDown () { Left = 50, Top=50, Width=400 };
                            Button confirmation = new Button() { Text = "Ok", Left=350, Width=100, Top=70 };
                            confirmation.Click += (sender, e) => { prompt.Close(); };
                            prompt.Controls.Add(confirmation);
                            prompt.Controls.Add(textLabel);
                            prompt.Controls.Add(inputBox);
                            prompt.ShowDialog();
                            return (int)inputBox.Value;
                        }
                    }
                

                然后调用它:

                 int promptValue = Prompt.ShowDialog("Test", "123");
                

                这篇关于创建返回值的自定义对话框的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Windows 窗体中是否有内置确认对话框? 下一篇:在 C# 中手动复制文件时显示复制文件对话框/表单?

                相关文章

                <tfoot id='b4gT7'></tfoot>

                  • <bdo id='b4gT7'></bdo><ul id='b4gT7'></ul>
                  <legend id='b4gT7'><style id='b4gT7'><dir id='b4gT7'><q id='b4gT7'></q></dir></style></legend>
                  <i id='b4gT7'><tr id='b4gT7'><dt id='b4gT7'><q id='b4gT7'><span id='b4gT7'><b id='b4gT7'><form id='b4gT7'><ins id='b4gT7'></ins><ul id='b4gT7'></ul><sub id='b4gT7'></sub></form><legend id='b4gT7'></legend><bdo id='b4gT7'><pre id='b4gT7'><center id='b4gT7'></center></pre></bdo></b><th id='b4gT7'></th></span></q></dt></tr></i><div id='b4gT7'><tfoot id='b4gT7'></tfoot><dl id='b4gT7'><fieldset id='b4gT7'></fieldset></dl></div>

                    <small id='b4gT7'></small><noframes id='b4gT7'>