Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Select from string array in Properties grid

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

    Select from string array in Properties grid

    Bertrand has kindly provided a reference sample of various customised property grid items (https://ninjatrader.com/support/foru...ad.php?t=97919).

    I would appreciate a simple example for both NT7 and NT8 of a property grid dropdown to select from an array of strings.

    Most grateful for your assistance in this.

    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Look carefully at the provided NT8 sample reference.

    Even though that reference file is designed for NT8, the C# code inside the region 'Use Case #4: Display "friendly" enum values' will probably work in NT7.

    Also, if you're a member of BMT, an example exists here,

    Comment


      #3
      Hello jeronymite,

      I am unaware of an existing sample I could provide for this. For NT7 there weren't many samples related to the property grid on the support forum because NT7 uses the standard .net property grid that comes with Windows Forms. You can find a lot of complete examples online for Windows Forms property grid and the various properties it supports which also would work in NT7. Going forward in nt8 a custom property grid is used so there are some key differences which in turn allows us to provide more samples of it.

      Here is one example of a dropdown in C# using the winforms property grid: https://stackoverflow.com/a/24509383 which resulted from searching for the terms "C# winforms propertygrid dropdown".

      I look forward to being of further assistance.

      Comment


        #4
        Select from string array in Properties grid

        Thanks Jesse and bltdavid. Very helpful.

        I have it working in both NT7 and NT8 as follows, specifically for a range of string values (hence the variable names). But I want to make it a bit more generic, so will continue to work on it.

        Common:
        Code:
        		public class StringSelectorConverter : TypeConverter
        		{
        			public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        			{
        				return true ;
        			}
        			public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        			{
        				StandardValuesCollection svc = new StandardValuesCollection(selection) ;
        				return svc ;
        			}
        		}
        		
        		static class RangeList
        		{
        			public static List<string> ranges = new List<string>() ;
        			static RangeList()
        			{
        				foreach (string sel in plotrangetype)
        					ranges.Add(sel) ;
        			}
        		}
        NT7:
        Code:
        		[Description("Range Selector.")]
        		[Category("Range Data")]
        		[Gui.Design.DisplayNameAttribute("Range")]
        		[RefreshProperties(RefreshProperties.All)]
        		[TypeConverter(typeof(StringSelectorConverter))]
        		public string _RangeSelection
        		{
        			get { return  RangeSelection ; }
        			set { RangeSelection = value ; }
        		}
        NT8:
        Code:
        		[TypeConverter(typeof(StringSelectorConverter))]
        		[PropertyEditor("NinjaTrader.Gui.Tools.StringStandardValuesEditorKey")]
        		[Display(ResourceType = typeof(Custom.Resource), Name = "Range", GroupName = "Range Data", Order = 4,
        				 Description="Range Selector.")]
        		public string _RangeSelection
        		{
        			get { return  RangeSelection; }
        			set { RangeSelection= value ; }
        		}
        Thanks.
        Multi-Dimensional Managed Trading
        jeronymite
        NinjaTrader Ecosystem Vendor - Mizpah Software

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X