Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Switch Tabs Programmatically

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

    Switch Tabs Programmatically

    Is there any way to get a list of the tabs within a Chart and/or switch tabs programmatically?

    OnWindowCreated is only called once for a chart window, and I was having difficulty finding/iterating thru the tabs.

    Also, would be nice to have a hot key to switch to next tab within a chart window.

    #2
    Hello aslane,

    Finding the TabControl of the chart is not documented in the help guide, however, it is possible to find as a child of the window.

    Below is a link to the help guide for the TabControl for Addons which is the same type of object.


    I am not aware of a way to programmatically change the selected tab on a chart. Would you like to submit a feature request for this?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      The hot key should be a feature request for sure, so you can cycle thru the tabs of a window.

      Comment


        #4
        Hello aslane,

        You may be able to set the TabControl.SelectedIndex.

        Below is a publicly available link to a 3rd party site on TabControl.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks, that is the direction I was headed next. First I had to get all of the tabs (originally, I was confused because OnWindowCreated is only called once per window, not once per tab). After iterating thru the tree, I have a better understanding of the structure.

          Comment


            #6
            Hi guys,

            Just curious if anyone has some more info to post on this subject.

            Aslane, do you have any sample code that you'd be able to share. I'm looking to switch to a tab based on symbol and timeframe, so for example if a tab has an alert come up by an indicator, bring up that tab automatically.

            Thanks
            mrlogik
            NinjaTrader Ecosystem Vendor - Purelogik Trading

            Comment


              #7
              Once you have a Chart, you can grab the tab controller and do as you want.
              Code:
              Chart chartWindow = window as Gui.Chart.Chart;
              if (chartWindow != null)
              {
                      foreach (TabItem ti in chartWindow.MainTabControl.Items)
                      {
                          ChartTab ct = ti.Content as Gui.Chart.ChartTab;
                          
                          if (ct != null)
                          ...
                      }
              }
              Once you have the right tab, just set the selected index - see tab controller doc mentioned before for more.

              Comment


                #8
                Perfect, thank you!
                mrlogik
                NinjaTrader Ecosystem Vendor - Purelogik Trading

                Comment


                  #9
                  Originally posted by aslane View Post
                  Once you have a Chart, you can grab the tab controller and do as you want.
                  Code:
                  Chart chartWindow = window as Gui.Chart.Chart;
                  if (chartWindow != null)
                  {
                  foreach (TabItem ti in chartWindow.MainTabControl.Items)
                  {
                  ChartTab ct = ti.Content as Gui.Chart.ChartTab;
                  
                  if (ct != null)
                  ...
                  }
                  }
                  Once you have the right tab, just set the selected index - see tab controller doc mentioned before for more.
                  aslane, how do you get the chart window? is there a way without using an AddOn?

                  I have 2 windows... with chart tabs.. but I don't know how to differentiate between them programatically? one is linked by instrument to the market anaylzer.. the other I manually switch the tabs because those charts have strategies running on them. However, I'd like to code something so that when the linked chart changes its instrument then I can focus in the unlinked chart window to the tab that has the same instrument (if one exists)

                  do you think this is possible to do?

                  Comment


                    #10
                    Originally posted by NinjaCustomer View Post

                    aslane, how do you get the chart window? is there a way without using an AddOn?
                    ?
                    If you have a chartControl (or panel) you can find the visual parent of specific type (Chart which is the chart window). You can start with

                    I know this is no ground breaking, mind blowing secret trick, but I have been getting a surprising number of questions regarding how to find the parent of...


                    and then do something like:

                    Chart chartWindow = FindParent<Chart>(chartControl);

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by KennyK, 05-29-2017, 02:02 AM
                    2 responses
                    1,278 views
                    0 likes
                    Last Post marcus2300  
                    Started by fernandobr, Today, 09:11 AM
                    0 responses
                    0 views
                    0 likes
                    Last Post fernandobr  
                    Started by itrader46, Today, 09:04 AM
                    1 response
                    3 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by timmbbo, Today, 08:59 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post timmbbo
                    by timmbbo
                     
                    Started by bmartz, 03-12-2024, 06:12 AM
                    5 responses
                    33 views
                    0 likes
                    Last Post NinjaTrader_Zachary  
                    Working...
                    X