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 8540389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:35:12+00:00 2026-06-11T11:35:12+00:00

How to access to property of property in object instance using string ? I

  • 0

How to access to property of property in object instance using string ?
I would like automate changes i will made in form for example responding to object below:

class myObject{
   Vector3 position;
   public myObject(){
       this.position = new Vector3( 1d,2d,3d);
   }
};

Form have eg three numericUpDown called respectively position_X,position_Y,position_Z;
Instead having three callbacks for events as:

private void positionX_ValueChanged(object sender, EventArgs e)
  { 
    // this.model return myObject
    this.model().position.X = (double)  ((NumericUpDown)sender).Value;

  }

I would have one callback which can automatically set particular attribute in model from control name/tag

Below is javascript which describe purpose i want 🙂

position_Changed( sender ){
   var prop = sender.Tag.split('_'); ; // sender.Tag = 'position_X';      
   this.model[ prop[0] ] [ prop[1] ] = sender.Value;
}
  • 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-06-11T11:35:13+00:00Added an answer on June 11, 2026 at 11:35 am

    You can use either reflection or expression trees to do that.

    The simple reflection way (not very fast but versatile):

    object model = this.model();
    object position = model.GetType().GetProperty("position").GetValue(model);
    position.GetType().GetProperty("X").SetValue(position, ((NumericUpDown)sender).Value);
    

    Note: if Vector3 is a struct you may not get the expected results (but that has to do with structs and boxing, not with the code per se).

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

Sidebar

Related Questions

I am trying to access a property of instance object using the following code
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Possible Duplicate: javascript object, access variable property name? I'm trying to call a method
I created an object literal in JS, but wanna to access a property without
is it possible to access a static property of a COM object without creating
D2.0 classes have a __monitor class property that gives access to the class object's
I want to access text-shadow property just like we access padding property. Means ,
I was previously using the application object to cache data that never changes. I
I want to access the property storedValue from the class method popOperandOffStack: , but
I need to be able to access a property via reflection, and, knowing that

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.