c# - How to clear the text of all textBoxes in the form or in The groupBox

c# - How to clear the text of all textBoxes in the form or in The groupBox

                                                                                        

In This C# Tutorial We Will See How You Can Remove The Text From All TextBoxes In The Form Or In The GroupBox Using CSharp Programming Language..


Source Code :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Clear_TextBoxes : Form
    {
        public Clear_TextBoxes()
        {
            InitializeComponent();
        }

        private void BTN_FORM_Click(object sender, EventArgs e)
        {
            foreach(Control c in Controls)
            {
                if(c is TextBox)
                {
                    c.Text = "";
                }
            }
        }

        private void BTN_GRBX_Click(object sender, EventArgs e)
        {
            foreach (Control c in groupBox1.Controls)
            {
                if (c is TextBox)
                {
                    c.Text = "";
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            BTN_FORM.PerformClick();
            BTN_GRBX.PerformClick();
        }
    }

}
=> OutPut :

Clear All TextBoxes In C#
Clear All TextBoxes In C#



Share this

Related Posts

Previous
Next Post »