<tfoot id='FAbBP'></tfoot>
  1. <small id='FAbBP'></small><noframes id='FAbBP'>

      <bdo id='FAbBP'></bdo><ul id='FAbBP'></ul>

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

      Windows 窗体中的提示对话框

      时间:2023-09-14

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

          • <small id='nqa55'></small><noframes id='nqa55'>

              <tbody id='nqa55'></tbody>
              • <bdo id='nqa55'></bdo><ul id='nqa55'></ul>
                <legend id='nqa55'><style id='nqa55'><dir id='nqa55'><q id='nqa55'></q></dir></style></legend>
              • 本文介绍了Windows 窗体中的提示对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用 System.Windows.Forms 但奇怪的是没有能力创建它们.

                I am using System.Windows.Forms but strangely enough don't have the ability to create them.

                如何在没有 javascript 的情况下获得类似 javascript 提示对话框的内容?

                How can I get something like a javascript prompt dialog, without javascript?

                MessageBox 不错,但用户无法输入.

                MessageBox is nice, but there is no way for the user to enter an input.

                我希望用户输入任何可能的文本输入.

                I want the user to enter any text input possible.

                推荐答案

                您需要创建自己的提示对话框.您也许可以为此创建一个类.

                You need to create your own Prompt dialog. You could perhaps create a class for this.

                public static class Prompt
                {
                    public static string ShowDialog(string text, string caption)
                    {
                        Form prompt = new Form()
                        {
                            Width = 500,
                            Height = 150,
                            FormBorderStyle = FormBorderStyle.FixedDialog,
                            Text = caption,
                            StartPosition = FormStartPosition.CenterScreen
                        };
                        Label textLabel = new Label() { Left = 50, Top=20, Text=text };
                        TextBox textBox = new TextBox() { Left = 50, Top=50, Width=400 };
                        Button confirmation = new Button() { Text = "Ok", Left=350, Width=100, Top=70, DialogResult = DialogResult.OK };
                        confirmation.Click += (sender, e) => { prompt.Close(); };
                        prompt.Controls.Add(textBox);
                        prompt.Controls.Add(confirmation);
                        prompt.Controls.Add(textLabel);
                        prompt.AcceptButton = confirmation;
                
                        return prompt.ShowDialog() == DialogResult.OK ? textBox.Text : "";
                    }
                }
                

                并称它为:

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

                更新:

                添加了默认按钮(输入键)和基于评论的初始焦点和另一个问题.

                Added default button (enter key) and initial focus based on comments and another question.

                这篇关于Windows 窗体中的提示对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:从 Lucene Query 获取不同值的更快方法 下一篇:获取C#保存对话框的文件路径

                相关文章

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

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