當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。