Announcement

Collapse
No announcement yet.

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 Gerik, Today, 12:35 PM
1 response
5 views
0 likes
Last Post NinjaTrader_PaulH  
Started by i2w8am9ii2, Today, 12:33 PM
2 responses
10 views
0 likes
Last Post Aftermath  
Started by mkt_anomalies, Today, 12:26 PM
1 response
9 views
0 likes
Last Post NinjaTrader_Jim  
Started by aaadetos, Today, 10:55 AM
1 response
14 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by Hyper, Today, 08:32 AM
4 responses
27 views
0 likes
Last Post Hyper
by Hyper
 
Working...
X