using System.Reflection;
PropertyInfo[] pis = null; //对象所有属性组成的集合 propertys
string val = null;
ent = new myClass(); //ent 为控件或者类实例
ent = Control ctrl;
pis = ent.GetType().GetProperties();
foreach (PropertyInfo pi in pis)
{
val = pi.GetValue(ent, null) + ""; //取得的值
if (pi.Name != "ID" && val != "" && pi.CanWrite && pi.PropertyType == typeof(string))
{
pi.SetValue(ent, "设置的值", null);
}
}