• 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();
                }
            }

  • 相关阅读:
    hdu_2842_Chinese Rings(矩阵快速幂)
    hdu_3565_Bi-peak Number(数位DP)
    hdu_1536_S-Nim(DFS_SG博弈)
    hdu_1848_Fibonacci again and again(博弈sg函数)
    hdu_2147_kiki's game(博弈)
    hdu_2955_Robberies(01背包)
    hdu_5705_Clock("巴卡斯杯" 中国大学生程序设计竞赛
    [POJ2104]K-th Number
    【AHOI2014复仇】
    最长回文子串
  • 原文地址:https://www.cnblogs.com/emily_fly/p/1423966.html
Copyright © 2020-2023  润新知