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

UI properties in a Class

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

    UI properties in a Class

    Is it possible to put UI properties in a Class so as to reduce the amount of code needed when you have a lot of controls? I've attached a simple example with a class that has 1 UI control and then I've created two instances of the class. However, the controls do not show on the UI. I am fairly new to C# so I am guessing this is user error/lack of understanding. Thanks in advance for the help.
    Attached Files

    #2
    Hello swcooke,

    If you wanted to group properties in a class you can certainly do that.

    To have it displayed in the user interface would also require that you make a public property.

    Right now you have a List<S> which you have not provided a modifier for. If you don't specify, it's going to just be private by default. Also, a list would need a collection editor to be displayed which brings up the question, Do you want a list of items or an object with many properties or both?

    Starting with the most simple is the class as that would be the basis for any of the mentioned approaches. You can find an example of an expandable class object here: https://ninjatrader.com/support/foru...179#post510179

    For more complex scenarios where you do actually need a collection or to do other modifications, see the following post:


    You can further combine these items together to make complex property grids for the user interface, but please keep in mind that this may display differently in different tools. With that in mind, please make sure to test all situations the script is used in to confirm your logic works as expected and throws no errors.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi swcooke,

      Yes, it is possible. That's the idea behind expandable properties. It is a bit tricky to implement in that you'll have to write your own ICustomTypeDescriptor interface to modify the property grid.Unless you really need it, don't do it.
      Attached Files

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cre8able, Today, 03:20 PM
      0 responses
      1 view
      0 likes
      Last Post cre8able  
      Started by Fran888, 02-16-2024, 10:48 AM
      3 responses
      45 views
      0 likes
      Last Post Sam2515
      by Sam2515
       
      Started by martin70, 03-24-2023, 04:58 AM
      15 responses
      114 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by The_Sec, Today, 02:29 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by jeronymite, 04-12-2024, 04:26 PM
      2 responses
      31 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X