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

Unsupported C# question...

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

    Unsupported C# question...

    I'm simply trying to open a Form within the chart clientarea. Somehow, this eludes me. I've tried all the examples I've found and none of them work. I'm missing something. I guess the child does not really know who the parent is. When I do fHelp.Show(this); It's receiving NinjaScript.Indicator and not System.Windows.Form; and throws an error. Any help would be greatly appreciated


    using System.Windows.Form;

    public class MyIndicator : Indicator
    {

    private Form fHelp;

    private void tsHelpBtn_Click(object sender, EventArgs e)
    {
    fHelp = new Form();
    fHelp.StartPosition = FormStartPosition.CenterParent;
    fHelp.Owner = (Form)ChartControl.Parent; // even tried that to no avail

    fHelp.Show();
    }

    }

    #2
    I'm looking at some code someone else did to compare. Sorry, I can't release it.

    But... the major difference I see is this person used is "this." in front of all like I demonstrate in your code.

    It's worth a shot. Other than that, I probably have no clue.


    Code:
    private void tsHelpBtn_Click(object sender, EventArgs e)
    {
    this.fHelp = new Form();
    this.fHelp.StartPosition = FormStartPosition.CenterParent;
    this.fHelp.Owner = (Form)ChartControl.Parent; // even tried that to no avail
    
    this.fHelp.Show();
    }
    Originally posted by funk101 View Post
    I'm simply trying to open a Form within the chart clientarea. Somehow, this eludes me. I've tried all the examples I've found and none of them work. I'm missing something. I guess the child does not really know who the parent is. When I do fHelp.Show(this); It's receiving NinjaScript.Indicator and not System.Windows.Form; and throws an error. Any help would be greatly appreciated


    using System.Windows.Form;

    public class MyIndicator : Indicator
    {

    private Form fHelp;

    private void tsHelpBtn_Click(object sender, EventArgs e)
    {
    fHelp = new Form();
    fHelp.StartPosition = FormStartPosition.CenterParent;
    fHelp.Owner = (Form)ChartControl.Parent; // even tried that to no avail

    fHelp.Show();
    }

    }

    Comment


      #3
      Hello funk101,

      Thank you for your post.

      What is the error reported when when you do fHelp.Show(this);?

      I look forward to assisting you further.

      Comment


        #4
        Originally posted by NinjaTrader_PatrickH View Post
        Hello funk101,

        Thank you for your post.

        What is the error reported when when you do fHelp.Show(this);?

        I look forward to assisting you further.
        See attached image
        Attached Files

        Comment


          #5
          Originally posted by funk101 View Post
          I'm simply trying to open a Form within the chart clientarea. Somehow, this eludes me. I've tried all the examples I've found and none of them work. I'm missing something. I guess the child does not really know who the parent is. When I do fHelp.Show(this); It's receiving NinjaScript.Indicator and not System.Windows.Form; and throws an error. Any help would be greatly appreciated


          using System.Windows.Form;

          public class MyIndicator : Indicator
          {

          private Form fHelp;

          private void tsHelpBtn_Click(object sender, EventArgs e)
          {
          fHelp = new Form();
          fHelp.StartPosition = FormStartPosition.CenterParent;
          fHelp.Owner = (Form)ChartControl.Parent; // even tried that to no avail

          fHelp.Show();
          }

          }
          Try using this post as a starting point?

          ref: http://www.ninjatrader.com/support/f...79&postcount=4

          Comment


            #6
            Hello funk101,

            Thank you for your response.

            And thanks to Koganam for his post on this matter. I am not sure of the resolution to your error here, as you mention this is an unsupported area. Please let me know if the suggestion by Koganam resolves the matter.

            Comment


              #7
              Originally posted by koganam View Post
              Try using this post as a starting point?

              ref: http://www.ninjatrader.com/support/f...79&postcount=4
              Yes my friend, that was totally it. Creating the class HelpForm(){} .

              public class HelpForm : Form
              {
              public Label lblTitle;

              public HelpForm()
              {
              ClientSize = new Size(400, 100);
              StartPosition = FormStartPosition.CenterScreen;
              lblTitle = new Label();
              lblTitle.Size = new Size(400, 50);
              lblTitle.Location = new Point(10, 10);
              lblTitle.Text = "Hello World";
              Controls.Add(lblTitle);
              }

              }

              then instantiate on button_Click() put's the form right in the center of chart. Thanks again

              Comment


                #8
                Originally posted by NinjaTrader_PatrickH View Post
                Hello funk101,

                Thank you for your response.

                And thanks to Koganam for his post on this matter. I am not sure of the resolution to your error here, as you mention this is an unsupported area. Please let me know if the suggestion by Koganam resolves the matter.
                Yes that helped. See my post.
                Thanks

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by GwFutures1988, Today, 02:48 PM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by ScottWalsh, 04-16-2024, 04:29 PM
                6 responses
                28 views
                0 likes
                Last Post ScottWalsh  
                Started by frankthearm, Today, 09:08 AM
                10 responses
                36 views
                0 likes
                Last Post frankthearm  
                Started by mmenigma, Today, 02:22 PM
                1 response
                3 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by NRITV, Today, 01:15 PM
                2 responses
                9 views
                0 likes
                Last Post NRITV
                by NRITV
                 
                Working...
                X