C# pour Compact FM 1.1, retrouver un Control en ayant le nom
FredArmoni
Messages postés153Date d'inscriptionvendredi 2 mai 2003StatutModérateurDernière intervention 2 avril 2010
-
12 sept. 2005 à 10:40
TheSaib
Messages postés2367Date d'inscriptionmardi 17 avril 2001StatutMembreDernière intervention26 décembre 2007
-
1 déc. 2005 à 01:35
J'utilise la fonction de Redo (convertie en C#) :
using System.Reflection
public Control FindControl(System.Windows.Forms.Control.ControlCollection myForm, string name )
{
foreach( Control myCt in myForm )
{
FieldInfo[] fi = myCt.Parent.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase);
foreach (FieldInfo f in fi)
{
if ( f.Name.Replace("_", null) == name)
{
if (f.GetValue(myCt.Parent).Equals(myCt))
{
return myCt;
}
}
}
}
return null;
}
or, celle-ci déclenche un exception argumentNullValue sur le Replace...
une info?
[mailto:frederic.steczycki@mvps.org Fred]
membre actif d'AtoutFox
A voir également:
C# pour Compact FM 1.1, retrouver un Control en ayant le nom