示例#1
0
        public static string Show(string text, string caption)
        {
            RadForm prompt = new RadForm();

            prompt.Width           = 500;
            prompt.Height          = 150;
            prompt.FormBorderStyle = FormBorderStyle.FixedDialog;
            prompt.Text            = caption;
            prompt.StartPosition   = FormStartPosition.CenterScreen;
            prompt.Anchor          = AnchorStyles.Right;
            prompt.ShowIcon        = false;

            RadLabel textLabel = new RadLabel()
            {
                Left = 50, Top = 20, Text = text, AutoSize = true
            };
            RadTextBox textBox = new RadTextBox()
            {
                Left = 50, Top = 50, Width = 400
            };
            RadButton confirmation = new RadButton()
            {
                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 : "");
        }
示例#2
0
        public static DialogResult InputBox(this Form f, string title, string promptText, ref string value)
        {
            RadForm    form         = new RadForm();
            RadLabel   label        = new RadLabel();
            RadTextBox textBox      = new RadTextBox();
            RadButton  buttonOk     = new RadButton();
            RadButton  buttonCancel = new RadButton();

            form.Text    = title;
            label.Text   = promptText;
            textBox.Text = value;

            buttonOk.Text             = "OK";
            buttonCancel.Text         = "Cancel";
            buttonOk.DialogResult     = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 18, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize      = true;
            textBox.Anchor      = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize      = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;
            form.AcceptButton    = buttonOk;
            form.CancelButton    = buttonCancel;

            DialogResult dialogResult = form.ShowDialog();

            value = textBox.Text;
            return(dialogResult);
        }
示例#3
0
        public static string Show(string text, string caption)
        {
            RadForm prompt = new RadForm();
            prompt.Width = 500;
            prompt.Height = 150;
            prompt.FormBorderStyle = FormBorderStyle.FixedDialog;
            prompt.Text = caption;
            prompt.StartPosition = FormStartPosition.CenterScreen;
            prompt.Anchor = AnchorStyles.Right;
            prompt.ShowIcon = false;

            RadLabel textLabel = new RadLabel() { Left = 50, Top = 20, Text = text, AutoSize = true };
            RadTextBox textBox = new RadTextBox() { Left = 50, Top = 50, Width = 400 };
            RadButton confirmation = new RadButton() { 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 : "";
        }
示例#4
0
 public static void ShowModalForm(RadForm form)
 {
     form.ShowDialog();
 }