遍历panel 上的控件,然后操作

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Controls;

namespace CsharpTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnAdd_Click(object sender, EventArgs e)
{
foreach(Control c in this.panelEx1.Controls)
{
if(c is DevComponents.DotNetBar.Controls.TextBoxX)
{
c.Text
= "123";
}
else
{
c.Text
= "名称!";
}
}
}

private void btnClear_Click(object sender, EventArgs e)
{
foreach(Control d in this.panelEx1.Controls)
{
if(d is DevComponents.DotNetBar.Controls.TextBoxX)
{
d.Text
= "";
}
else
{
d.Text
= "更改后的名称";
}
}
}
}
}
private void ClearText()
{
foreach (Control myControl in this.panelTable.Controls)
{
if (myControl is DevComponents.DotNetBar.LabelX)
{
continue;
}

myControl.Text
= "";
}
}
原文地址:https://www.cnblogs.com/beeone/p/2012600.html