System.Windows.Forms.TextBox.Clear C# (CSharp) Method

Clear() public method

public Clear ( ) : void
return void
		public void Clear()
		{
			this.Text = string.Empty;	
		}
		public HorizontalAlignment TextAlign

Usage Example

Example #1
0
        //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;
        }
All Usage Examples Of System.Windows.Forms.TextBox::Clear