Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

How to loop through all Properties

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Zeos6
    replied
    Glad it worked out for you.

    Leave a comment:


  • cassb
    replied
    Originally posted by Zeos6 View Post
    You can do this (loop through your properties) by implementing the ICustomTypeDescriptor interface and then using GetProperties().
    Thanks, Zeos! I ended up just typing in all my properties one by one though, instead of making a neat loop. Oh well... it works at least. :-)

    Bryan

    Leave a comment:


  • Zeos6
    replied
    You can do this (loop through your properties) by implementing the ICustomTypeDescriptor interface and then using GetProperties().
    Last edited by Zeos6; 09-03-2012, 08:29 AM.

    Leave a comment:


  • cassb
    replied
    Originally posted by NinjaTrader_AdamP View Post
    cass,

    Here is some more information on get and set : http://msdn.microsoft.com/en-us/library/w86s7x04.aspx
    Yes, thank you I've been reading that already. But I think I need some construct that I don't yet know in c# in order to get the setter to be called regardless of whether the value changed or not. Something like [Bindable] maybe... I'm not sure. I'll have to see if I can find some c# code examples out there that do this.

    Thanks!

    Leave a comment:


  • NinjaTrader_AdamP
    replied
    cass,

    Here is some more information on get and set : http://msdn.microsoft.com/en-us/library/w86s7x04.aspx

    Leave a comment:


  • cassb
    replied
    Originally posted by NinjaTrader_AdamP View Post
    cassb,

    This would be a C# feature unfortunately. Get/Set are both parts of C#.
    OK -- yes a little experimentation and I see that Get is called every time the parameter field is displayed, even if you are just scrolling the parameter list up and down. It gets called a zillion times! So this may not do it for me. I need to have something called when the user exits that field, regardless of whether the value changed or not. The Set accessor is not the answer, apparently.

    Is there a FieldExit event or something I can use to do this?

    Leave a comment:


  • NinjaTrader_AdamP
    replied
    cassb,

    This would be a C# feature unfortunately. Get/Set are both parts of C#.

    Leave a comment:


  • cassb
    replied
    OK, thanks Adam!

    I have a related question then... you'll notice that if you click on a parameter value and change it to something different and then hit Tab or Return, then the get/set accessors are called. However, if you click on a parameter value and change it to the same value it already was, then the get/set is not called. I have some code in the 'set' that I want called regardless of whether you changed the parameter value or not, as long as you clicked on it. Is this a NT limitation or a C# feature?

    Thanks!
    Bryan

    Edit: Wait... maybe the "get" is called when you first access the parameter field? I could put my code into that instead of "set"... I'll try that first.

    Leave a comment:


  • NinjaTrader_AdamP
    replied
    cass,

    Unfortunately there is no way to do this via supported methods as these are separate variables, not arrays or lists.

    You may find this useful however : http://en.wikipedia.org/wiki/Reflect...er_programming)

    And this : http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx

    Leave a comment:


  • cassb
    started a topic How to loop through all Properties

    How to loop through all Properties

    Can you tell me what the internal structure is so I can write a For loop to go through all my public properties that are defined in the Properties region?

    Thanks!
    Bryan

Latest Posts

Collapse

Topics Statistics Last Post
Started by DJ888, 04-16-2024, 06:09 PM
6 responses
18 views
0 likes
Last Post DJ888
by DJ888
 
Started by Jon17, Today, 04:33 PM
0 responses
1 view
0 likes
Last Post Jon17
by Jon17
 
Started by Javierw.ok, Today, 04:12 PM
0 responses
6 views
0 likes
Last Post Javierw.ok  
Started by timmbbo, Today, 08:59 AM
2 responses
10 views
0 likes
Last Post bltdavid  
Started by alifarahani, Today, 09:40 AM
6 responses
41 views
0 likes
Last Post alifarahani  
Working...
X