Je reçois des propriétés de l'enfant d'un objet avec ce code,Définition d'une valeur du problème de la propriété enfant d'un objet
PropertyDescriptorCollection childProperties = TypeDescriptor.GetProperties (theObject) [childNode.Name] .GetChildProperties();
pense que la variable "theObject" est un TextBox et j'essaie de définir TextBox.Font.Bold = true;
J'utilise ce code pour les propriétés principales et cela fonctionne lorsque je personnalise pour les propriétés principales. Mais quand j'accède aux propriétés enfant,
Je reçois une erreur qui est "Référence d'objet non définie à une instance d'un objet.".
foreach (PropertyDescriptor childProperty in childProperties)
{
foreach (XmlAttribute attribute in attributes)
{
if (childProperty.Name == attribute.Name)
{
if (!childProperty.IsReadOnly)
{
object convertedPropertyValue = ConverterHelper.ConvertValueForProperty(attribute.Value, childProperty);
childProperty.SetValue(theObject, convertedPropertyValue); //exception throw here
break;
}
}
}
}
Pouvez-vous coller l'exception complète s'il vous plaît –