zoukankan      html  css  js  c++  java
  • C#中的输入框函数

    private string InputBox(string Caption, string Hint, string Default)
            {
                Form InputForm = new Form();
                InputForm.MinimizeBox = false;
                InputForm.MaximizeBox = false;
                InputForm.StartPosition = FormStartPosition.CenterScreen;
                InputForm.Width = 220;
                InputForm.Height = 150;

                InputForm.Text = Caption;
                Label lbl = new Label();
                lbl.Text = Hint;
                lbl.Left = 10;
                lbl.Top = 20;
                lbl.Parent = InputForm;
                lbl.AutoSize = true;
                TextBox tb = new TextBox();
                tb.Left = 30;
                tb.Top = 45;
                tb.Width = 160;
                tb.Parent = InputForm;
                tb.Text = Default;
                tb.SelectAll();
                Button btnok = new Button();
                btnok.Left = 30;
                btnok.Top = 80;
                btnok.Parent = InputForm;
                btnok.Text = "确定";
                InputForm.AcceptButton = btnok;//回车响应

                btnok.DialogResult = DialogResult.OK;
                Button btncancal = new Button();
                btncancal.Left = 120;
                btncancal.Top = 80;
                btncancal.Parent = InputForm;
                btncancal.Text = "取消";
                btncancal.DialogResult = DialogResult.Cancel;
                try
                {
                    if (InputForm.ShowDialog() == DialogResult.OK)
                    {
                        return tb.Text;
                    }
                    else
                    {
                        return null;
                    }
                }
                finally
                {
                    InputForm.Dispose();
                }
            }

  • 相关阅读:
    腾讯、阿里、网易、杰士邦等30家中秋月饼设计盘点!(完整版)
    腾讯、阿里、网易、杰士邦等30家中秋月饼设计盘点!(完整版)
    最挑战程序员的9大任务,你都干过哪些?
    这些代码优化的方法,你都用过吗?
    这些代码优化的方法,你都用过吗?
    6-13/6-14/6-15
    机器学习实验二-集成学习
    Windows下python3登陆和操作linux服务器
    什么是CDN?
    VI.应用-Trajectory Data Mining
  • 原文地址:https://www.cnblogs.com/emily_fly/p/1423966.html
Copyright © 2011-2022 走看看