SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Fri Sep 21, 2018 9:30 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Forms?
PostPosted: Sat Apr 26, 2008 12:49 am 
Offline

Joined: Thu Apr 17, 2008 10:21 am
Posts: 21
what's wrong with this code please?

Code:
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Drawing;

using OpenQuant.API;
using OpenQuant.API.Indicators;


public class MyScript : Script{public override void Run();}
   public class Form1 : Form
{
   public Button button1;
   public Form1()
   {
      button1 = new Button();
      button1.Size = new Size(40, 40);
      button1.Location = new Point(30, 30);
      button1.Text = "Click me";
      this.Controls.Add(button1);
      button1.Click += new EventHandler(button1_Click);
   }
   private void button1_Click(object sender, EventArgs e)
   {
      MessageBox.Show("Hello World");
   }

}


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 05, 2008 4:35 pm 
Offline

Joined: Thu Mar 20, 2008 4:41 pm
Posts: 273
Location: Sweden
What's the error message you get?

I changed to

Code:
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Drawing;

using OpenQuant.API;
using OpenQuant.API.Indicators;


public class MyScript : Script{
   public override void Run() {
      Form1 test = new Form1();
   }
}
public class Form1 : Form
{
   public Button button1;
   public Form1() {
      button1 = new Button();
      button1.Size = new Size(40, 40);
      button1.Location = new Point(30, 30);
      button1.Text = "Click me";
      this.Controls.Add(button1);
      button1.Click += new EventHandler(button1_Click);
   }
   private void button1_Click(object sender, EventArgs e)
   {
      MessageBox.Show("Hello World");
   }

}

And the code now runs, but does nothing. Not sure why, I don't really understand forms.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 05, 2008 4:43 pm 
Offline

Joined: Thu Mar 20, 2008 4:41 pm
Posts: 273
Location: Sweden
I understand you want a button, and a event that triggers when the button is pressed, but I'm not sure where you expect the button to show up?
Isn't it necessary to create a form somewhere?
like form someform = new form(); ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 05, 2008 5:10 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6808
I think you should have

Code:
Application.Run(Form);


somewhere.

Regards,
Anton


Top
 Profile  
 
 Post subject: Re: Forms?
PostPosted: Fri Sep 14, 2012 8:45 am 
Offline

Joined: Thu Jun 08, 2006 3:56 pm
Posts: 537
Location: BC Canada
Just to update this thread for future use, with a pointer to more threading info, and a sample Form to run.

http://www.smartquant.com/forums/viewtopic.php?f=64&t=7740


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group