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


C# TextBox.Clear方法代码示例

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


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

示例1: PrintRadacini

 public void PrintRadacini(TextBox tb)
 {
     tb.Clear();
     for (int i = 0; i < radacini.Count; i++) {
         tb.AppendText(radacini[i] + "\n");
     }
 }
开发者ID:alexflorea,项目名称:CN,代码行数:7,代码来源:Function.cs

示例2: ShowDialog

        public static string ShowDialog(string text, string caption, string initalValue="")
        {
            Label textLabel = new Label() { Left = 30, Top = 5, Width = 200, Text = text };
            TextBox textBox = new TextBox() { Left = 30, Top = 35, Width = 200, Text = initalValue };
            Button confirmation = new Button() { Text = "Ok", Left = 105, Width = 70, Top = 80 };
            Button cancel = new Button() { Text = "Cancel", Left = 180, Width = 70, Top = 80 };
            Form prompt = new Form {Text = caption, ShowIcon = false, AcceptButton = confirmation, CancelButton = cancel,
                AutoSize = true, MaximizeBox = false, MinimizeBox = false, AutoSizeMode = AutoSizeMode.GrowAndShrink,
                SizeGripStyle = SizeGripStyle.Hide, ShowInTaskbar = false, StartPosition = FormStartPosition.CenterParent};

            confirmation.Click += (sender, e) =>
                {
                    prompt.DialogResult = DialogResult.OK;
                    prompt.Close();
                };
            cancel.Click += (sender, e) =>
                {
                    textBox.Clear();
                    prompt.DialogResult = DialogResult.Cancel;
                    prompt.Close();
                };

            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(cancel);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(textBox);
            prompt.ActiveControl = textBox;

            var result = prompt.ShowDialog();

            return result == DialogResult.OK ? textBox.Text.Trim() : null;
        }
开发者ID:JohnChantzis,项目名称:bark_GUI,代码行数:32,代码来源:InputBox.cs

示例3: Drawer

        public Drawer(TextBox monitor, TextBox resultMonitor, DataGridView grid, DataGridView grid2)
        {
            this._monitor = monitor;
            this._resultMonitor = resultMonitor;
            this._grid = grid;
            this._grid2 = grid2;
            _table = new DataTable();
            _triangularTable = new DataTable();
            _table.Columns.Add("A1", typeof(int));
            _table.Columns.Add("A2", typeof(int));
            _table.Columns.Add("A3", typeof(int));
            _table.Columns.Add("A4", typeof(int));
            _table.Columns.Add("C", typeof(int));
            _triangularTable.Columns.Add("A1", typeof(int));
            _triangularTable.Columns.Add("A2", typeof(int));
            _triangularTable.Columns.Add("A3", typeof(int));
            _triangularTable.Columns.Add("A4", typeof(int));
            _triangularTable.Columns.Add("C", typeof(int));
            grid.DataSource = _table;
            grid2.DataSource = _triangularTable;
            _monitor.Clear();
            _resultMonitor.Clear();

            Solver.UpdateMatrix += SolverUpdateMatrix;
            Solver.UpdateGridRepresentation += Solver_UpdateGridRepresentation;
            Solver.CalculationComplete += Solver_CalculationComplete;
            Solver.ReversePassComplete += Solver_ReversePassComplete;
            Solver.RowsSwaped += Solver_RowsSwaped;
        }
开发者ID:Mr-Zoidberg,项目名称:SLAEByGauss,代码行数:29,代码来源:Drawer.cs

示例4: button2_Click

        private void button2_Click(object sender, EventArgs e)
        {
            TextBox txtBoxXi = new TextBox();
            txtBoxXi = (TextBox)Controls.Find("txtBoxXi", true).FirstOrDefault();
            TextBox txtBoxYi = new TextBox();
            txtBoxYi = (TextBox)Controls.Find("txtBoxYi", true).FirstOrDefault();

            if (txtBoxXi.Text != "" && txtBoxYi.Text != "")
            {
                if (VerificaSeENumero(txtBoxXi) && VerificaSeENumero(txtBoxYi))
                {
                    listaX.Add(Convert.ToDouble(txtBoxXi.Text));
                    listaY.Add(Convert.ToDouble(txtBoxYi.Text));
                    itm = new ListViewItem(new[] { txtBoxXi.Text, txtBoxYi.Text });
                    listView2.Items.Add(itm);

                    listView2.GridLines = true;
                    listView2.View = View.Details;
                    listView2.FullRowSelect = true;
                    listView2.Update();
                }
                txtBoxXi.Clear();
                txtBoxYi.Clear();
            }
        }
开发者ID:ramonjija,项目名称:MatematicaComputacional,代码行数:25,代码来源:Form1.cs

示例5: control_readonly

        //改变文本框读写权限,控制计费类型对应关系
        public void control_readonly(ComboBox s_FeeType, TextBox n_Period, TextBox n_FixMoney,TextBox n_FeeRatio,TextBox n_NumFrom,TextBox n_NumTo)
        {
            if (s_FeeType.Text.Trim() == "按张计费")
            {
                n_Period.ReadOnly = true;
                n_FixMoney.ReadOnly = true;

                n_Period.Clear();
                n_FixMoney.Clear();

                n_FeeRatio.ReadOnly = false;
                n_NumFrom.ReadOnly = false;
                n_NumTo.ReadOnly = false;
            }
            if (s_FeeType.Text.Trim() == "周期性固定计费")
            {
                n_FeeRatio.ReadOnly = true;
                n_NumFrom.ReadOnly = true;
                n_NumTo.ReadOnly = true;

                n_FeeRatio.Clear();
                n_NumFrom.Clear();
                n_NumTo.Clear();

                n_Period.ReadOnly = false;
                n_FixMoney.ReadOnly = false;
            }
        }
开发者ID:TGHGH,项目名称:Warehouse-2,代码行数:29,代码来源:BargainDAO.cs

示例6: isPresentTextBox

        //data validation for textbox presence
        //extra logic for if the textbox is the color textbox
        public bool isPresentTextBox(TextBox textbox, string name)
        {
            if (textbox == txtColor)
            {
                if (textbox.Text == "")
                {
                    MessageBox.Show(name + " is a required field.  Enter N/A if not applicable.", "Error");
                    textbox.Clear();
                    textbox.Focus();
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
            {
                if (textbox.Text == "")
                {
                    MessageBox.Show(name + " is a required field", "Error");
                    textbox.Clear();
                    textbox.Focus();
                    return false;
                }
            }

            return true;
        }
开发者ID:jlarson497,项目名称:InventoryManagement,代码行数:31,代码来源:Form1.cs

示例7: AddNew

 private void AddNew(TextBox txtWord, int iListIndex)
 {
     if (string.IsNullOrWhiteSpace(txtWord.Text)) {
         return;
     }
     insults.AddToList(iListIndex, txtWord.Text);
     txtWord.Clear();
 }
开发者ID:Ald0s,项目名称:facebook-autoreplier,代码行数:8,代码来源:Insults.cs

示例8: loadIMDBArrayListInfo

 private void loadIMDBArrayListInfo(IMDb imdb, ArrayList list, TextBox txtBox)
 {
     txtBox.Clear();
     for (int i = 0; i < list.Count; i++)
     {
         txtBox.Text += list[i].ToString() + ", ";
     }
 }
开发者ID:thefoofighter,项目名称:M_View,代码行数:8,代码来源:Form1.cs

示例9: FillMemo

 public static void FillMemo(TextBox lb, List<string> list)
 {
     lb.Clear();
     foreach(var s in list) {
         if (lb.Text.Length > 0)
         lb.AppendText(Environment.NewLine);
         lb.AppendText(s);
     }
 }
开发者ID:emm274,项目名称:fcObj,代码行数:9,代码来源:xedits.cs

示例10: isPresent

 //presence validation
 public bool isPresent(TextBox textbox, string name)
 {
     if (textbox.Text == "")
     {
         MessageBox.Show(name + " is a required field", "Error");
         textbox.Clear();
         textbox.Focus();
         return false;
     }
     return true;
 }
开发者ID:jlarson497,项目名称:Project7-1,代码行数:12,代码来源:Form1.cs

示例11: Document

        // Creates new, empty document
        public Document(TextBox ScriptTextBox, ListView ListView1)
        {
            m_ScriptTextBox = ScriptTextBox;
            m_ListView1 = ListView1;
            m_FileName = null;
            m_TasksGenerated = false;

            m_ScriptTextBox.Clear(); // Causes OnScriptTextChanged call, but we don't mind
            m_ListView1.Items.Clear();
            m_ScriptTextBox.Modified = false;
        }
开发者ID:sawickiap,项目名称:FxBatchCompiler,代码行数:12,代码来源:Document.cs

示例12: IsDecimal

 //decimal type validation
 public bool IsDecimal(TextBox textbox, string name)
 {
     decimal number = 0;
     if (decimal.TryParse(textbox.Text, out number))
     {
         return true;
     }
     else
     {
         MessageBox.Show(name + " must be a decimal.", "Entry Error");
         textbox.Clear();
         textbox.Focus();
         return false;
     }
 }
开发者ID:jlarson497,项目名称:Project7-1,代码行数:16,代码来源:Form1.cs

示例13: IsInt

 //Data type validation for INT
 public bool IsInt(TextBox textbox, string name)
 {
     int number = 0;
     if (int.TryParse(textbox.Text, out number))
     {
         return true;
     }
     else
     {
         MessageBox.Show(name + " must be an integer.", "Entry Error");
         textbox.Clear();
         textbox.Focus();
         return false;
     }
 }
开发者ID:jlarson497,项目名称:InventoryManagement,代码行数:16,代码来源:Form1.cs

示例14: tbToDecimal

        public decimal tbToDecimal(TextBox tb, string errMessage = "")
        {
            decimal num = 0m;
            if (tb.Text.Length == 0) return num;

            try
            {
                num = Convert.ToDecimal(tb.Text);
                tb.Clear();
            }
            catch (FormatException e)
            {
                errMessage = (errMessage.Length > 0 ? errMessage : e.Message);
                MessageBox.Show(errMessage);
            }

            return num;
        }
开发者ID:kietnguyen,项目名称:cpsc-462-pos,代码行数:18,代码来源:TextBoxParser.cs

示例15: tbToInt

        /// <summary>
        /// 
        /// </summary>
        /// <param name="str"></param>
        /// <param name="errMessage"></param>
        /// <param name="defaultIfBlank"></param>
        /// <returns></returns>
        public int tbToInt(TextBox tb, string errMessage = "", bool OneIfBlank = false)
        {
            int num = 0;
            if (tb.Text == "")
                return 1;

            try
            {
                num = Convert.ToInt32(tb.Text);
                tb.Clear();
            }
            catch (FormatException e)
            {
                errMessage = (errMessage.Length > 0 ? errMessage : e.Message);
                MessageBox.Show(errMessage);
            }

            return num;
        }
开发者ID:kietnguyen,项目名称:cpsc-462-pos,代码行数:26,代码来源:TextBoxParser.cs


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