C#如何清空多个textbox的中的文本!
1个回答
展开全部
详细代码如下:
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace test{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){foreach (Control c in this.Controls)//遍历窗体上所有控件Controls为所有窗体上控件的集合{if (c is TextBox)//判断某个控件是否TextBox{
c.Text = ""; //清空TextBox里面文本内容}}}}}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace test{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){foreach (Control c in this.Controls)//遍历窗体上所有控件Controls为所有窗体上控件的集合{if (c is TextBox)//判断某个控件是否TextBox{
c.Text = ""; //清空TextBox里面文本内容}}}}}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询