private TextBox GetTextBox( Control ctrl )
{
if( ctrl.Name == "textbox1" )
return (TextBox)ctrl;
else if( ctrl.Controls.Count!=0 )
foreach( Control subCtrl in ctrl.Controls )
{
TextBox tb = GetTextBox(subCtrl);
if(tb!=null)
return tb;
}
else
return null;
}然后在你要获取的地方:TextBox tb = GetTextBox( this );
{
if( ctrl.Name == "textbox1" )
return (TextBox)ctrl;
else if( ctrl.Controls.Count!=0 )
foreach( Control subCtrl in ctrl.Controls )
{
TextBox tb = GetTextBox(subCtrl);
if(tb!=null)
return tb;
}
else
return null;
}然后在你要获取的地方:TextBox tb = GetTextBox( this );
Class A
{
......................
}
string className = "A";
A obj ;
Type classType = Type.GetType(className);
//这里classType 总为null???
if(classType != null)
{
obj = (A)Activator.CreateInstance(classType);
obj.execute();
}