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


C# TextBox.SelectAll方法代码示例

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


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

示例1: ProcessRecord

        protected override void ProcessRecord()
        {
            var files = Directory.GetFiles(SessionState.Path.CurrentLocation.Path, SearchPattern);

            if (files.Length > 0)
            {
                StringBuilder builder = new StringBuilder();

                foreach (var file in files)
                {
                    builder.AppendLine(file);
                }

                TextBox clipStore = new TextBox();
                clipStore.Text = builder.ToString();
                clipStore.Multiline = true;
                clipStore.SelectAll();
                clipStore.Copy();

                WriteObject(string.Format("({0}) files copied.", files.Length));
            }
            else
            {
                WriteError(new ErrorRecord(new NullReferenceException("No Files to copy"), "0301", ErrorCategory.InvalidArgument, files));
            }
        }
开发者ID:krozen20,项目名称:redshells,代码行数:26,代码来源:WriteClipboardCommand.cs

示例2: NextFocus

 public static void NextFocus(TextBox tb, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && !bEnter)
     {
         bEnter = true;
         tb.Focus();
         tb.SelectAll();
     }
 }
开发者ID:vuchannguyen,项目名称:lg-py,代码行数:9,代码来源:SubFuntion.cs

示例3: CheckAndParseValue

        private bool CheckAndParseValue(TextBox textBox, out int value)
        {
            if (int.TryParse(textBox.Text, out value))
                return true;

            MessageBox.Show(this, "Invalid numeric format!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            textBox.SelectAll();
            textBox.Focus();
            return false;
        }
开发者ID:ktj007,项目名称:Lz,代码行数:10,代码来源:FormResize.cs

示例4: CheckNumTextBox

        /// <summary>
        /// 檢查文本框的內容是否輸入正確
        /// </summary>
        /// <param name="target"></param>
        /// <param name="textType"></param>
        /// <returns></returns>
        public static bool CheckNumTextBox(TextBox target, enmTextBoxValueType textType, enmNumCheckType checkType)
        {
            switch (textType)
            {
                case enmTextBoxValueType.enmInt:
                    int intValue = 0;
                    if(!int.TryParse(target.Text,out intValue))
                    {
                        target.SelectAll();
                        target.Focus();
                        return false;
                    }

                    if (checkType == enmNumCheckType.enmNotAllowZero && intValue == 0)
                    {
                        target.SelectAll();
                        target.Focus();
                        return false;
                    }

                    break;
                case enmTextBoxValueType.enmDecimal:
                    decimal decValue = 0;
                    if (!decimal.TryParse(target.Text, out decValue))
                    {
                        target.SelectAll();
                        target.Focus();
                        return false;
                    }

                    if (checkType == enmNumCheckType.enmNotAllowZero && decValue == 0)
                    {
                        target.SelectAll();
                        target.Focus();
                        return false;
                    }

                    break;
            }

            return true;
        }
开发者ID:Klutzdon,项目名称:SIOTS_HHZX,代码行数:48,代码来源:CommonFunction.cs

示例5: IsEqualTo

 public static bool IsEqualTo(TextBox txt1, TextBox txt2)
 {
     if (txt1.Text == txt2.Text)
     {
         return true;
     }
     MessageBox.Show("Passwords must be equal.");
     txt1.Focus();
     txt1.SelectAll();
     return false;
 }
开发者ID:rhoddog77,项目名称:CaseStudy,代码行数:11,代码来源:Validator.cs

示例6: EhDecimal

 //Criar um método para converter em decimal
 private decimal EhDecimal(TextBox txt)
 {
     try
     {
         return Convert.ToDecimal(txt.Text);
     }
     catch
     {
         txt.Focus();
         txt.SelectAll();
         throw new Exception("Informe apenas números");
     }
 }
开发者ID:tca85,项目名称:ASP.NET,代码行数:14,代码来源:calculadoraForm.cs

示例7: EhShort

 public static short EhShort(TextBox txt)
 {
     try
     {
         return Convert.ToInt16(txt.Text);
     }
     catch (Exception)
     {
         txt.Focus();
         txt.SelectAll();
         throw new Exception("Informe um ano válido");
     }
 }
开发者ID:tca85,项目名称:ASP.NET,代码行数:13,代码来源:Geral.cs

示例8: CreateTextBox

 private void CreateTextBox(LinkLabel label)
 {
     text = new TextBox();
     text.Text = label.Text;
     text.Location = label.Location;
     text.Size = label.Size;
     text.BorderStyle = BorderStyle.FixedSingle;
     text.BackColor = Color.CornflowerBlue;
     mainPanel.Controls.Add(text);
     text.BringToFront();
     text.KeyPress += new KeyPressEventHandler(text_KeyPress);
     text.Focus();
     text.SelectAll();
 }
开发者ID:davidajulio,项目名称:hx,代码行数:14,代码来源:Talk.cs

示例9: TahVazio

 public static string TahVazio(TextBox txt)
 {
     if (txt.Text.Trim() != "")
     {
         return txt.Text;
     }
     else
     {
         txt.Focus();
         txt.SelectAll();
         throw new Exception("Preencha " 
             + txt.Name.Substring(0, txt.Name.Length-7));
     }
 }
开发者ID:tca85,项目名称:ASP.NET,代码行数:14,代码来源:Geral.cs

示例10: CheckAndParseValue

        private bool CheckAndParseValue(TextBox textBox, out string value)
        {
            if (!string.IsNullOrWhiteSpace(textBox.Text))
            {
                value = textBox.Text.Trim();
                return true;
            }

            MessageBox.Show(this, "Invalid name!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            textBox.SelectAll();
            textBox.Focus();

            value = null;
            return false;
        }
开发者ID:ktj007,项目名称:Lz,代码行数:15,代码来源:FormRename.cs

示例11: EstaVazio

 public static string EstaVazio(TextBox txt)
 {
     if (txt.Text.Trim() != "")
     {
         return txt.Text;
     }
     else
     {
         txt.Focus();
         txt.SelectAll();
         throw new Exception("Preencha o (a): " +  txt.Name.Substring(3));
         //substring é igual ao mid do VB. Dessa forma, estou especificando para pegar o texto
         //que está depois do txt dos nomes que eu especifico. ex: txtNome, txtModelo
         //se meu padrão de nomes fosse nomeTextBox usaria: txt.Name.Substring(0, txtName.Length - 7));
     }
 }
开发者ID:tca85,项目名称:ASP.NET,代码行数:16,代码来源:clsGeral.cs

示例12: IsInt

 public static bool IsInt(TextBox textBox)
 {
     if (IsPresent(textBox))
     {
         try
         {
             Convert.ToInt32(textBox.Text);
             return true;
         }
         catch (FormatException)
         {
             MessageBox.Show(string.Format("{0} must be an integer number.", textBox.Tag), Title);
             textBox.Focus();
             textBox.SelectAll();
         }
     }
     return false;
 }
开发者ID:rhoddog77,项目名称:CaseStudy,代码行数:18,代码来源:Validator.cs

示例13: ValidarCPF

        public void ValidarCPF(TextBox txt, Label lbl)
        {
            int soma = 0;
            string dv = "";

            if (txt.Text.Length != 11)
            {
                lbl.BackColor = Color.Orange;
                lbl.ForeColor = Color.Red;
                lbl.Text = "I N C O N S I S T E N T E";
            }
            else
            {
                //1º DV
                for (int i = 8; i >= 0; i--)
                {
                    soma += Convert.ToInt32(txt.Text.Substring(i, 1)) * (i + 1);
                }
                dv = Convert.ToString(soma % 11 % 10);

                //2º DV
                soma = 0;
                for (int i = 9; i >= 1; i--)
                {
                    soma += Convert.ToInt32(txt.Text.Substring(i, 1)) * i;
                }
                dv += Convert.ToString(soma % 11 % 10);

                if (dv == txt.Text.Substring(9, 2))
                {
                    lbl.BackColor = Color.Green;
                    lbl.ForeColor = Color.Yellow;
                    lbl.Text = "V Á L I D O";
                }
                else
                {
                    lbl.BackColor = Color.Red;
                    lbl.ForeColor = Color.White;
                    lbl.Text = "N Ã O  V Á L I D O";
                }
                txt.Focus();
                txt.SelectAll();
            }
        }
开发者ID:tca85,项目名称:ASP.NET,代码行数:44,代码来源:Documento.cs

示例14: IsEmail

 public static bool IsEmail(TextBox textBox)
 {
     if (IsPresent(textBox))
     {
         try
         {
             MailAddress address = new MailAddress(textBox.Text);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message + " [email protected]");
             textBox.Focus();
             textBox.SelectAll();
             return false;
         }
         return true;
     }
     return false;
 }
开发者ID:rhoddog77,项目名称:CaseStudy,代码行数:19,代码来源:Validator.cs

示例15: InputBox

        /// <summary>
        /// 输入对话框
        /// </summary>
        /// <param name="caption">标题</param>
        /// <param name="hint">提示内容</param>
        /// <param name="Default">默认值</param>
        /// <returns></returns>
        public static string InputBox(string caption, string hint, string Default)
        {
            Form inputForm = new Form
            {
                MinimizeBox = false,
                MaximizeBox = false,
                StartPosition = FormStartPosition.CenterScreen,
                Width = 220,
                Height = 150,
                Text = caption
            };

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

            btnok.DialogResult = DialogResult.OK;
            Button btncancal = new Button
            {
                Left = 120,
                Top = 80,
                Parent = inputForm,
                Text = "取消",
                DialogResult = DialogResult.Cancel
            };
            try
            {
                return inputForm.ShowDialog() == DialogResult.OK ? tb.Text : null;
            }
            finally
            {
                inputForm.Dispose();
            }
        }
开发者ID:Dason1986,项目名称:Lib,代码行数:43,代码来源:InputDialog.cs


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