编程遍历WinForm页面上所有TextBox控件并给它赋值为string.Empty

博客给出一段代码,通过foreach循环遍历窗体中的控件,判断若为文本框,则将其文本内容清空,是信息技术领域关于窗体控件操作的代码示例。

foreach (System.Windows.Forms.Control control in this.Controls)
{
if (control is System.Windows.Forms.TextBox)
{
System.Windows.Forms.TextBox tb = (System.Windows.Forms.TextBox)control ;
tb.Text = String.Empty ; }
}

public class Class1 { private static int _idCounter = 1; // 自增ID计数器 public int ID { get; } = _idCounter++; // 自动分配唯一ID public string hpw { get; set; } public string one { get; set; } public string two { get; set; } public string three { get; set; } public string fourname { get; set; } public float fiveX { get; set; } public float sexY { get; set; } public string sevenname { get; set; } public float eightX { get; set; } public float nineY { get; set; } // 组合坐标显示 public string FournameWithCoords => $"{fourname} ({fiveX}, {sexY})"; public string SevennameWithCoords => $"{sevenname} ({eightX}, {nineY})"; }在vs2019里winform通过读取hpw文件使用pictureBox实现X轴,Y轴的数据呈现原点形状出来且可以框选可以放大缩小也可以通过x轴镜像与y轴镜像,通过换算屏幕坐标到我实际的数据坐标来使dataGridView点击名称通过名称里读取到的hpw文件的x轴与y轴来进行绿色叉号的闪烁标注镜像过后的坐标也得换算成数据坐标呈现出来,通过得到的x轴与y轴坐标来进行与0,0的最近点与最远点计算(),附在textbox里,不管怎么镜像在程序内部将所有坐标转换为第二象限来进行对控制卡的移动,通过hpw文件提供的最远点与最近点,再从控制卡里得到脉冲然后换算成点位来得到位移加角度的数据位置然后控制运动卡去移动,生成我需求提供的所有代码以及类然后控制卡的不用提供但是角度位移换算需要提供,换算后也是要到第二象限
最新发布
03-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值