Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 348365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:21:28+00:00 2026-05-12T11:21:28+00:00

I get child properties of an object with this code, PropertyDescriptorCollection childProperties = TypeDescriptor.GetProperties(theObject)[childNode.Name].GetChildProperties();

  • 0

I get child properties of an object with this code,

PropertyDescriptorCollection childProperties = TypeDescriptor.GetProperties(theObject)[childNode.Name].GetChildProperties();

think that “theObject” variable is a TextBox and I try to set TextBox.Font.Bold = true;

I use this code for main properties and it works when I customize for main properties. But when I access the child properties,

I get an error which is “Object reference not set to an instance of an object.”.

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;
                    }
                }
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:21:28+00:00Added an answer on May 12, 2026 at 11:21 am

    It looks like you are passing the wrong object to SetValue – on the face of it it looks like you get something like:

    <TextBox>
      <Font Bold="true"/>
    </Textbox>
    

    And then you get the Font property of the text box and the Bold property of the font and then you try to assign the value true to the Bold property of TextBox. Obviously this is not going to work.

    Maybe something like this:

    PropertyDescriptor objProp = TypeDescriptor.GetProperties(theObject)[childNode.Name];
    PropertyDescriptorCollection childProperties = objProp.GetChildProperties();
    
    foreach (PropertyDescriptor childProperty in childProperties) {
        foreach (XmlAttribute attribute in attributes) {
            if (childProperty.Name == attribute.Name && !childProperty.IsReadOnly) {
                Object convertedPropertyValue = converterHelper.ConvertValueForProperty(attribute.Value, childProperty);
                childProperty.SetValue(objProp.getValue(theObject), convertedPropertyValue);
            }
        }
    }
    

    Note that the context for setting properties of the child object is the child object and not the parent object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get the first child id inside the div using JQuery. Sample code:
How i can get via Xpath distinct child nodes name that the name mached
This question shows how to get properties of parent views. Is there a way
I've created an object that contains another collection in one of it properties. This
I have a object structure like this: public class Entity { IList<Relationship> Relationships{get;set;} }
yes i want to get a child window of another application. Give me Sum
I am trying to get the child repeater's item count but for some reason
with $element->children() i cant get all the child elements of current element. but how
I need to get the Handler to the child Window of a certain application
How can I get the text value from an elements's child? Say I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.