In this blog we will know how to clear the text boxes values in windows application.
Method-1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Clear_textbox_windows
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
CleartextBoxes1();
}
public void CleartextBoxes1()
{
foreach (Control Cleartext in this.Controls)
{
if (Cleartext is TextBox)
{
((TextBox)Cleartext).Text = string.Empty;
}
}
}
}
}
Method-2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Clear_textbox_windows
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();

Virender KumarPosted Apr 16, 2019, 4:54 AM
It didn't work for me..