当前位置: 首页>>代码示例>>C#>>正文


C# TextBox.SetBounds方法代码示例

本文整理汇总了C#中System.Windows.Forms.TextBox.SetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.SetBounds方法的具体用法?C# TextBox.SetBounds怎么用?C# TextBox.SetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.TextBox的用法示例。


在下文中一共展示了TextBox.SetBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnPeople_Click

 void btnPeople_Click(object sender, EventArgs e)
 {
     System.Diagnostics.Debug.WriteLine(this.GetType().Attributes);
     Form f = new Form();
     Label lbl1, lbl2;
     TextBox txt1, txt2;
     f.Text = "WTF you are ?";
     f.SetBounds(10, 10, 200, 140);
     f.Controls.Add(lbl1 = new Label());
     lbl1.SetBounds(5, 5, 185,18);
     lbl1.Text = "firstname";
     f.Controls.Add(txt1 = new TextBox());
     txt1.SetBounds(5, 25, 185, 18);
     f.Controls.Add(lbl2 = new Label());
     lbl2.Text = "surname";
     lbl2.SetBounds(5, 45, 185, 18);
     f.Controls.Add(txt2 = new TextBox());
     txt2.SetBounds(5, 65, 185, 18);
     Button btn = new Button();
     btn.SetBounds(5, 85, 185, 18);
     btn.Text = "Add people";
     f.Controls.Add(btn);
     btn.Click += (object sender1, EventArgs e1) =>
     {
         this.chklistPeople.Items.Add(txt1.Text + " " + txt2.Text);
         //this.Show();
         //f.Close();
     };
     f.Show();
 }
开发者ID:NivekAlunya,项目名称:csharp,代码行数:30,代码来源:MainScreen.cs

示例2: FixControlSizes

 private static void FixControlSizes(Label label, TextBox textBox, Button buttonOk, Button buttonCancel)
 {
     label.SetBounds(9, 20, 372, 13);
     textBox.SetBounds(12, 36, 372, 20);
     buttonOk.SetBounds(228, 72, 75, 23);
     buttonCancel.SetBounds(309, 72, 75, 23);
 }
开发者ID:Vipeax,项目名称:GW2WinMan,代码行数:7,代码来源:InputBox.cs

示例3: inputBox

 public static DialogResult inputBox(string title, string labelText, ref string promptText)
 {
     Form form = new Form();
     Label label = new Label();
     Button buttonOk = new Button();
     Button buttonCancel = new Button();
     TextBox textBox = new TextBox();
     label.Text = labelText;
     form.Text = title;
     textBox.Text = promptText;
     buttonOk.Text = "Ok";
     buttonCancel.Text = "Cancelar";
     buttonOk.DialogResult = DialogResult.OK;
     buttonCancel.DialogResult = DialogResult.Cancel;
     form.AcceptButton = buttonOk;
     form.CancelButton = buttonCancel;
     label.SetBounds(9, 20, 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;
     DialogResult res = form.ShowDialog();
     promptText = textBox.Text;
     return res;
 }
开发者ID:luis-alberto-pena-nunez,项目名称:C-Sharp-Practice-004,代码行数:35,代码来源:InputBox.cs

示例4: InitEditors

        public void InitEditors()
        {
            const int startX = 20, labelWd = 170, labelHt = 18, editorWd = 100, editorLeft = 198;
            const int startY = 20, deltaY = 22;
            var row = 0;

            foreach (var ptr in CodeTemplate.parameters.Values)
            {
                var top = startY + (row++)*deltaY;
                // подпись
                var lbl = new Label {Text = ptr.Title, Parent = panelControls};
                lbl.SetBounds(startX, top, labelWd, labelHt);
                panelControls.Controls.Add(lbl);

                // редактор значения
                if (ptr.IsNumber || ptr.IsString)
                {
                    var textBox = new TextBox {Parent = panelControls};
                    textBox.SetBounds(editorLeft, top, editorWd, labelHt + 2);
                    panelControls.Controls.Add(textBox);
                    paramEditors.Add(textBox);
                }
                if (ptr.IsBoolean)
                {
                    var checkBox = new CheckBox {Parent = panelControls, Left = editorLeft, Top = top};
                    panelControls.Controls.Add(checkBox);
                    paramEditors.Add(checkBox);
                }
            }
        }
开发者ID:johnmensen,项目名称:TradeSharp,代码行数:30,代码来源:FormulaParameterForm.cs

示例5: Formulario

        public Formulario(int qtdeVariaveis, int qtdeRestricoes)
        {
            InitializeComponent();
            contadorEixoY = 40;
            for (int i = 0; i < qtdeRestricoes; i++)
            {
                contadorEixoX = 100;

                Label lbRestricoes = new Label();
                lbRestricoes.SetBounds(10, contadorEixoY, 80, 25);
                lbRestricoes.Text = "Restricao " + (i+1).ToString();
                this.Controls.Add(lbRestricoes);

                for (int j = 0; j < qtdeVariaveis; j++)
                {
                    Label lbVariaveis = new Label();
                    lbVariaveis.SetBounds(contadorEixoX, 10, 30, 25);
                    lbVariaveis.Text = "X" + (j+1).ToString();
                    this.Controls.Add(lbVariaveis);

                    TextBox txt = new TextBox();
                    txt.SetBounds(contadorEixoX, contadorEixoY, 30, 30);
                    this.Controls.Add(txt);
                    contadorEixoX += 40;
                }
                contadorEixoY += 30;
            }
        }
开发者ID:JanaineB,项目名称:ProgramacaoLinear,代码行数:28,代码来源:Formulario.cs

示例6: Show

        /// <summary>
        /// Shows a dialog box with an input field.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="prompt"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static DialogResult Show(string title, string prompt, ref string value)
        {
            Form mForm = new Form();
            Label mLabel = new Label();
            TextBox mTextBox = new TextBox();
            Button mOKButton = new Button();

            mForm.Text = title;
            mLabel.Text = prompt;
            mTextBox.Text = value;

            mOKButton.Text = "OK";
            mOKButton.DialogResult = DialogResult.OK;

            mForm.ClientSize = new Size(240, 80);
            mLabel.SetBounds(4, 4, mForm.ClientSize.Width-8, 22);
            mTextBox.SetBounds(32, 26, mForm.ClientSize.Width - 64, 24);
            mOKButton.SetBounds(mForm.ClientSize.Width / 2 - 32, 54, 64, 22);

            mLabel.AutoSize = true;
            mTextBox.Anchor = AnchorStyles.Bottom;
            mOKButton.Anchor = AnchorStyles.Bottom;

            mForm.Controls.AddRange(new Control[] { mLabel, mTextBox, mOKButton });
            mForm.FormBorderStyle = FormBorderStyle.FixedDialog;
            mForm.StartPosition = FormStartPosition.CenterScreen;
            mForm.MinimizeBox = false;
            mForm.MaximizeBox = false;
            mForm.AcceptButton = mOKButton;

            DialogResult dialogResult = mForm.ShowDialog();
            value = mTextBox.Text;
            return dialogResult;
        }
开发者ID:dogmahtagram,项目名称:Finale,代码行数:41,代码来源:InputDialog.cs

示例7: addTextBox

 public void addTextBox(string text, int x, int y, int w, int h)
 {
     TextBox tb = new TextBox();
     tb.Name = text;
     tb.SetBounds(x, y, w, h);
     TextboxList.Add(tb);
     Controls.Add(tb);
 }
开发者ID:jPalazon,项目名称:AppImagenes,代码行数:8,代码来源:Traces.cs

示例8: Show

        public static DialogResult Show(string title, string promptText, ref string value,
                                        InputBoxValidation validation)
        {
            Form form = new Form();
            Label label = new Label();
            TextBox textBox = new TextBox();
            Button buttonOk = new Button();
            Button buttonCancel = new Button();

            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, 20, 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;
            if (validation != null)
            {
                form.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (form.DialogResult == DialogResult.OK)
                    {
                        string errorText = validation(textBox.Text);
                        if (e.Cancel = (errorText != ""))
                        {
                            MessageBox.Show(form, errorText, "Validation Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            textBox.Focus();
                        }
                    }
                };
            }
            DialogResult dialogResult = form.ShowDialog();
            value = textBox.Text;
            return dialogResult;
        }
开发者ID:EAGLE-I,项目名称:HandKNN,代码行数:57,代码来源:InputBox.cs

示例9: Show

        /// <summary>
        /// Muestra el 'InputTextBox'
        /// </summary>
        /// <param name="strTexto"> Texto a mostrar en el mensaje </param>
        /// <param name="strEncabezado"> Título del InputTextBox </param>
        /// <param name="strValor"> Texto ingresado </param>
        /// <param name="itbValidacion"> Delegado que valida lo ingresado en el InputTextBox </param>
        /// <returns>DialogResult</returns>
        public static DialogResult Show(string strTexto, string strEncabezado, ref string strValor, InputBoxValidation itbValidacion)
        {
            Form frmFormulario = new Form();
            Label lblEtiqueta = new Label();
            TextBox txtCajaTexto = new TextBox();
            Button btnOK = new Button();
            Button btnCancel = new Button();

            frmFormulario.Text = strEncabezado;
            lblEtiqueta.Text = strTexto;
            txtCajaTexto.Text = strValor;

            btnOK.Text = "OK";
            btnCancel.Text = "Cancel";
            btnOK.DialogResult = DialogResult.OK;
            btnCancel.DialogResult = DialogResult.Cancel;

            lblEtiqueta.SetBounds(9, 20, 372, 13);
            txtCajaTexto.SetBounds(12, 36, 372, 20);
            btnOK.SetBounds(228, 72, 75, 23);
            btnCancel.SetBounds(309, 72, 75, 23);

            lblEtiqueta.AutoSize = true;
            txtCajaTexto.Anchor = txtCajaTexto.Anchor | AnchorStyles.Right;
            btnOK.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            btnCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            frmFormulario.ClientSize = new Size(396, 107);
            frmFormulario.Controls.AddRange(new Control[] { lblEtiqueta, txtCajaTexto, btnOK, btnCancel });
            frmFormulario.ClientSize = new Size(Math.Max(300, lblEtiqueta.Right + 10), frmFormulario.ClientSize.Height);
            frmFormulario.FormBorderStyle = FormBorderStyle.FixedDialog;
            frmFormulario.StartPosition = FormStartPosition.CenterScreen;
            frmFormulario.MinimizeBox = false;
            frmFormulario.MaximizeBox = false;
            frmFormulario.AcceptButton = btnOK;
            frmFormulario.CancelButton = btnCancel;
            if (itbValidacion != null)
            {
                frmFormulario.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (frmFormulario.DialogResult == DialogResult.OK)
                    {
                        string errorText = itbValidacion(txtCajaTexto.Text);
                        if (e.Cancel = (errorText != ""))
                        {
                            MessageBox.Show(frmFormulario, errorText, "Mensaje",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtCajaTexto.Focus();
                        }
                    }
                };
            }
            DialogResult dialogResult = frmFormulario.ShowDialog();
            strValor = txtCajaTexto.Text;
            return dialogResult;
        }
开发者ID:sandtiago,项目名称:tesispucp,代码行数:64,代码来源:clsInputTextBox.cs

示例10: Show

        /// <summary>
        /// Displays a dialog with a prompt and textbox where the user can enter information
        /// </summary>
        /// <param name="title">Dialog title</param>
        /// <param name="promptText">Dialog prompt</param>
        /// <param name="value">Sets the initial value and returns the result</param>
        /// <returns>Dialog result</returns>
        public static DialogResult Show(Form parent, string title, string promptText, string checkText, ref string value, ref bool isChecked)
        {
            // TODO: button placement/size has been hardcoded for how it is used in this app.

            Form form = new Form();
            Label label = new Label();
            TextBox textBox = new TextBox();
            Button buttonOk = new Button();
            Button buttonCancel = new Button();
            CheckBox checkBox = new CheckBox();
            form.Text = title;
            label.Text = promptText;
            textBox.Text = value;
            textBox.Multiline = true;
            textBox.Height = (int)(textBox.Height * 2);
            checkBox.Checked = isChecked;
            checkBox.Text = checkText;
            checkBox.Visible = (checkText != null);

            //form.TopLevel = true;
            //form.StartPosition = FormStartPosition.CenterParent;
            //form.Parent = parent;

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

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 76, 372, 50);
            buttonOk.SetBounds(228, 130, 75, 23);
            buttonCancel.SetBounds(309, 130, 75, 23);
            checkBox.SetBounds(12, 60, 150, 23);

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

            form.ClientSize = new Size(396, 170);

            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel, checkBox });
            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;
            isChecked = checkBox.Checked;
            return dialogResult;
        }
开发者ID:jlami,项目名称:mutefm,代码行数:63,代码来源:InputBoxWithCheck.cs

示例11: PeopleForm

 public PeopleForm(string title=null, IPeopleFormDelegate peopleFormDelegate = null, bool openForUpdate = false,string surname="", string firstname="", string password="", string comment="")
 {
     if (null != title) this.Text = title;
     _openForUpdate = openForUpdate;
     _peopleFormDelegate = peopleFormDelegate;
     this.SetBounds(10, 10, 200, 220);
     Label lbl1, lbl2,lbl3, lbl4;
     TextBox txt1, txt2,txt3,txt4;
     Button btn = new Button();
     this.Controls.Add(lbl1 = new Label());
     lbl1.SetBounds(5, 5, 185, 18);
     lbl1.Text = "firstname";
     this.Controls.Add(txt1 = new TextBox());
     txt1.SetBounds(5, 25, 185, 18);
     txt1.Text = firstname;
     this.Controls.Add(lbl2 = new Label());
     lbl2.Text = "surname";
     lbl2.SetBounds(5, 45, 185, 18);
     this.Controls.Add(txt2 = new TextBox());
     txt2.SetBounds(5, 65, 165, 18);
     txt2.Text = surname;
     this.Controls.Add(lbl3 = new Label());
     lbl3.SetBounds(5, 85, 185, 18);
     lbl3.Text = "password";
     this.Controls.Add(txt3 = new TextBox());
     txt3.SetBounds(5, 105, 185, 18);
     txt3.Text = password;
     this.Controls.Add(lbl4 = new Label());
     lbl4.SetBounds(5, 125, 185, 18);
     lbl4.Text = "comment";
     this.Controls.Add(txt4 = new TextBox());
     txt4.SetBounds(5, 145, 185, 18);
     txt4.Text = comment;
     this.Controls.Add(btn);
     btn.SetBounds(5, 165, 185, 18);
     ErrorProvider ep = new ErrorProvider();
     ep.SetIconAlignment(txt2, ErrorIconAlignment.MiddleRight);
     ep.SetIconPadding(txt2, 2);
     btn.Text = openForUpdate ? "Save people" : "Add people";
     btn.Click += (object sender1, EventArgs e1) =>
     {
         if (string.IsNullOrWhiteSpace(txt2.Text))
         {
             ep.SetError(txt2, "Surname must contain chars");
             return;
         }
         ep.SetError(txt2, string.Empty);
         if (null != this._peopleFormDelegate) _peopleFormDelegate.saved(txt2.Text, txt1.Text, txt3.Text, txt4.Text);
         if(openForUpdate) this.Close();
     };
 }
开发者ID:NivekAlunya,项目名称:csharp,代码行数:51,代码来源:FormPeople.cs

示例12: InitializeFindAndReplace

 /// <summary>
 /// Initialize find and replace.
 /// </summary>
 private void InitializeFindAndReplace()
 {
     FindText = new TextBox();
     FindText.Parent = this;
     FindText.MinimumSize = new Size(0, 0);
     FindText.MaximumSize = new Size(1, 1);
     FindText.SetBounds(0, 0, 1, 1);
     FindText.BackColor = Theme.BackColor;
     FindText.ForeColor = Theme.BackColor;
     FindText.TextChanged += new EventHandler(HandleFindTextChanged);
     FindText.KeyUp += new KeyEventHandler(HandleFindKeyUp);
     FindText.GotFocus += new EventHandler(HandleFindGotFocus);
     FindText.LostFocus += new EventHandler(HandleFindLostFocus);
 }
开发者ID:h3tch,项目名称:ProtoFX,代码行数:17,代码来源:CodeEditor.Find.cs

示例13: bAgregar_Click

 private void bAgregar_Click(object sender, EventArgs e)
 {
     TabPage Nueva = new TabPage("Archivo"+cont+".dx");
     TextBox texto = new TextBox();
     texto.Name = "texto";
     texto.Text = "";
     texto.Multiline = true;
     texto.SetBounds(0, 0, tabDx.Width, tabDx.Height);
     Nueva.Controls.Add(texto);
     tabDx.TabPages.Add(Nueva);
     cont++;
     tabDx.SelectedTab = Nueva;
     tabDx.ResetText();
 }
开发者ID:luiscmr,项目名称:Practica1_Compi2_2016,代码行数:14,代码来源:Form1.cs

示例14: InputBox

        public static DialogResult InputBox(string title, string promptText, out string value)
        {
            if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(promptText)) {
                value = null;
                return DialogResult.Abort;
            }

            Form form = new Form();
            Label label = new Label();
            TextBox textBox = new TextBox();

            textBox.Width = 1000;
            Button buttonOk = new Button();
            Button buttonCancel = new Button();

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

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

            label.SetBounds(9, 20, 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;
        }
开发者ID:Ryzhehvost,项目名称:ArchiSteamFarm,代码行数:47,代码来源:DialogBox.cs

示例15: createStackDisplay

        private void createStackDisplay()
        {
            TextBox box;

            for (int i = 0; i < PIC.Data.OperationStack.STACK_SIZE; i++)
            {
                box = new TextBox();
                box.SetBounds(5 + STACK_X_OFFSET, stackIndex0Label.Bounds.Y - TEXT_BOX_Y_OFFSET + i * 20, 25, 25);
                box.Parent = this;
                box.ReadOnly = true;
                box.Show();
                stackBoxes[i] = box;
            }

            updateStackDisplay();
            //throw new NotImplementedException();
        }
开发者ID:hipsterfister,项目名称:PIC16F84-Emulator,代码行数:17,代码来源:SpecialValueForm.cs


注:本文中的System.Windows.Forms.TextBox.SetBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。