• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to loop through all Properties

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

    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
    cassb
    NinjaTrader Ecosystem Vendor - Logical Forex

    #2
    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
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      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.
      cassb
      NinjaTrader Ecosystem Vendor - Logical Forex

      Comment


        #4
        cassb,

        This would be a C# feature unfortunately. Get/Set are both parts of C#.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          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?
          cassb
          NinjaTrader Ecosystem Vendor - Logical Forex

          Comment


            #6
            cass,

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

            Comment


              #7
              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!
              cassb
              NinjaTrader Ecosystem Vendor - Logical Forex

              Comment


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

                Comment


                  #9
                  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
                  cassb
                  NinjaTrader Ecosystem Vendor - Logical Forex

                  Comment


                    #10
                    Glad it worked out for you.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by dltharpe, Today, 09:17 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post dltharpe  
                    Started by HiddenPhilosopher, Today, 06:45 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post HiddenPhilosopher  
                    Started by PG7940, Today, 04:26 AM
                    0 responses
                    11 views
                    0 likes
                    Last Post PG7940
                    by PG7940
                     
                    Started by marcus2300, Today, 02:25 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post marcus2300  
                    Started by drpapp, 01-24-2019, 06:57 AM
                    5 responses
                    70 views
                    0 likes
                    Last Post pjsmith
                    by pjsmith
                     
                    Working...
                    X