Thankyou for your reply. Ive modified my code here so the control is
added when I click a menu item, the result is the same. I have a form
with, menustrip, tabcontrol showing one page with a treeview. I run
the form, click menuItem which adds a tabpage with the control.
private void eventsToolStripMenuItem_Click(object sender, EventArgs
e)
{
TabPage newPage = new TabPage("robs");
tabControl1.TabPages.Add(newPage);
tabControl1.SelectedTab = newPage;
MarketViewRow row = new MarketViewRow("rob");
row.Name = string.Format("{0}", 2222222);
row.Dock = DockStyle.Fill;
tabControl1.SelectedTab.Controls.Add(row);
m_marketViewRows[row.Name] = row;
}
my control:
public class MarketViewRow : System.Windows.Forms.UserControl
{
public PointPairList Backodds = new PointPairList();////graph
array
private System.Windows.Forms.Button lblRunner;
private System.Windows.Forms.Button btnBack;
private System.Windows.Forms.Button btnLay3;
private System.Windows.Forms.Button btnLay2;
private System.Windows.Forms.Button btnBack2;
private System.Windows.Forms.Button btnLay;
private System.Windows.Forms.Label btnBack3;
private ZedGraph.ZedGraphControl zedGraphControl1;
private ZedGraph.ZedGraphControl zedGraphControl2;
private SplitContainer splitContainer1;
private SplitContainer splitContainer2;
private SplitContainer splitContainer3;
private System.Windows.Forms.Label lblMarketid;
private System.Windows.Forms.Label lblExchangeid;
private System.Windows.Forms.Label lblSelectionid;
private System.Windows.Forms.Label lblhorse;
private System.ComponentModel.IContainer components;
public MarketViewRow(String Horse)
{
// This call is required by the Windows.Forms Form
Designer.
InitializeComponent();
lblRunner.Text = Horse;
ZedGraph.GraphPane zgc = zedGraphControl1.GraphPane;
zgc.Title.IsVisible = false;
zgc.XAxis.Title.IsVisible = false;
zgc.YAxis.Title.IsVisible = false;
zgc.AxisChange();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.lblRunner = new System.Windows.Forms.Button();
this.btnBack = new System.Windows.Forms.Button();
this.btnLay3 = new System.Windows.Forms.Button();
this.btnLay2 = new System.Windows.Forms.Button();
this.btnBack2 = new System.Windows.Forms.Button();
this.btnLay = new System.Windows.Forms.Button();
this.btnBack3 = new System.Windows.Forms.Label();
this.zedGraphControl1 = new ZedGraph.ZedGraphControl();
this.zedGraphControl2 = new ZedGraph.ZedGraphControl();
this.splitContainer1 = new
System.Windows.Forms.SplitContainer();
this.splitContainer2 = new
System.Windows.Forms.SplitContainer();
this.splitContainer3 = new
System.Windows.Forms.SplitContainer();
this.lblMarketid = new System.Windows.Forms.Label();
this.lblExchangeid = new System.Windows.Forms.Label();
this.lblSelectionid = new System.Windows.Forms.Label();
this.lblhorse = new System.Windows.Forms.Label();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
this.splitContainer3.Panel1.SuspendLayout();
this.splitContainer3.Panel2.SuspendLayout();
this.splitContainer3.SuspendLayout();
this.SuspendLayout();
//
// lblRunner
//
this.lblRunner.AccessibleRole =
System.Windows.Forms.AccessibleRole.None;
this.lblRunner.BackColor = System.Drawing.Color.White;
this.lblRunner.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblRunner.FlatStyle =
System.Windows.Forms.FlatStyle.Flat;
this.lblRunner.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblRunner.Location = new System.Drawing.Point(0, 0);
this.lblRunner.Name = "lblRunner";
this.lblRunner.Size = new System.Drawing.Size(502, 48);
this.lblRunner.TabIndex = 29;
this.lblRunner.UseVisualStyleBackColor = false;
this.lblRunner.UseWaitCursor = true;
//
// btnBack
//
this.btnBack.BackColor = System.Drawing.Color.LightBlue;
this.btnBack.Dock = System.Windows.Forms.DockStyle.Right;
this.btnBack.FlatStyle =
System.Windows.Forms.FlatStyle.Flat;
this.btnBack.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnBack.Location = new System.Drawing.Point(447, 0);
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(55, 48);
this.btnBack.TabIndex = 30;
this.btnBack.UseVisualStyleBackColor = false;
this.btnBack.UseWaitCursor = true;
//
// btnLay3
//
this.btnLay3.BackColor = System.Drawing.Color.White;
this.btnLay3.Dock = System.Windows.Forms.DockStyle.Right;
this.btnLay3.FlatStyle =
System.Windows.Forms.FlatStyle.Flat;
this.btnLay3.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnLay3.Location = new System.Drawing.Point(612, 0);
this.btnLay3.Name = "btnLay3";
this.btnLay3.Size = new System.Drawing.Size(55, 48);
this.btnLay3.TabIndex = 31;
this.btnLay3.UseVisualStyleBackColor = false;
this.btnLay3.UseWaitCursor = true;
//
// btnLay2
//
this.btnLay2.BackColor = System.Drawing.Color.White;
this.btnLay2.Dock = System.Windows.Forms.DockStyle.Right;
this.btnLay2.FlatStyle =
System.Windows.Forms.FlatStyle.Flat;
this.btnLay2.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnLay2.Location = new System.Drawing.Point(557, 0);
this.btnLay2.Name = "btnLay2";
this.btnLay2.Size = new System.Drawing.Size(55, 48);
this.btnLay2.TabIndex = 32;
this.btnLay2.UseVisualStyleBackColor = false;
this.btnLay2.UseWaitCursor = true;
//
// btnBack2
//
this.btnBack2.AccessibleRole =
System.Windows.Forms.AccessibleRole.None;
this.btnBack2.BackColor = System.Drawing.Color.White;
this.btnBack2.Dock = System.Windows.Forms.DockStyle.Right;
this.btnBack2.FlatStyle =
System.Windows.Forms.FlatStyle.Flat;
this.btnBack2.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnBack2.Location = new System.Drawing.Point(392, 0);
this.btnBack2.Name = "btnBack2";
this.btnBack2.Size = new System.Drawing.Size(55, 48);
this.btnBack2.TabIndex = 33;
this.btnBack2.UseVisualStyleBackColor = false;
this.btnBack2.UseWaitCursor = true;
//
// btnLay
//
this.btnLay.BackColor = System.Drawing.Color.Orchid;
this.btnLay.Dock = System.Windows.Forms.DockStyle.Right;
this.btnLay.FlatStyle =
System.Windows.Forms.FlatStyle.Flat;
this.btnLay.Font = new System.Drawing.Font("Microsoft Sans
Serif", 8F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnLay.Location = new System.Drawing.Point(502, 0);
this.btnLay.Name = "btnLay";
this.btnLay.Size = new System.Drawing.Size(55, 48);
this.btnLay.TabIndex = 34;
this.btnLay.UseVisualStyleBackColor = false;
this.btnLay.UseWaitCursor = true;
//
// btnBack3
//
this.btnBack3.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.btnBack3.Dock = System.Windows.Forms.DockStyle.Right;
this.btnBack3.Font = new System.Drawing.Font("Microsoft
Sans Serif", 9F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnBack3.Location = new System.Drawing.Point(337, 0);
this.btnBack3.Name = "btnBack3";
this.btnBack3.Size = new System.Drawing.Size(55, 48);
this.btnBack3.TabIndex = 35;
this.btnBack3.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
this.btnBack3.UseWaitCursor = true;
//
// zedGraphControl1
//
this.zedGraphControl1.Dock =
System.Windows.Forms.DockStyle.Fill;
this.zedGraphControl1.Location = new
System.Drawing.Point(0, 0);
this.zedGraphControl1.Name = "zedGraphControl1";
this.zedGraphControl1.ScrollGrace = 0;
this.zedGraphControl1.ScrollMaxX = 0;
this.zedGraphControl1.ScrollMaxY = 0;
this.zedGraphControl1.ScrollMaxY2 = 0;
this.zedGraphControl1.ScrollMinX = 0;
this.zedGraphControl1.ScrollMinY = 0;
this.zedGraphControl1.ScrollMinY2 = 0;
this.zedGraphControl1.Size = new System.Drawing.Size(667,
173);
this.zedGraphControl1.TabIndex = 37;
this.zedGraphControl1.UseWaitCursor = true;
//
// zedGraphControl2
//
this.zedGraphControl2.Dock =
System.Windows.Forms.DockStyle.Fill;
this.zedGraphControl2.Location = new
System.Drawing.Point(0, 0);
this.zedGraphControl2.Name = "zedGraphControl2";
this.zedGraphControl2.ScrollGrace = 0;
this.zedGraphControl2.ScrollMaxX = 0;
this.zedGraphControl2.ScrollMaxY = 0;
this.zedGraphControl2.ScrollMaxY2 = 0;
this.zedGraphControl2.ScrollMinX = 0;
this.zedGraphControl2.ScrollMinY = 0;
this.zedGraphControl2.ScrollMinY2 = 0;
this.zedGraphControl2.Size = new System.Drawing.Size(667,
251);
this.zedGraphControl2.TabIndex = 38;
this.zedGraphControl2.UseWaitCursor = true;
//
// splitContainer1
//
this.splitContainer1.Dock =
System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new
System.Drawing.Point(2, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation =
System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.splitContainer2);
this.splitContainer1.Panel1.UseWaitCursor = true;
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.zedGraphControl2);
this.splitContainer1.Panel2.UseWaitCursor = true;
this.splitContainer1.Size = new System.Drawing.Size(667,
509);
this.splitContainer1.SplitterDistance = 254;
this.splitContainer1.TabIndex = 39;
this.splitContainer1.UseWaitCursor = true;
//
// splitContainer2
//
this.splitContainer2.Dock =
System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.Location = new
System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
this.splitContainer2.Orientation =
System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.splitContainer3);
this.splitContainer2.Panel1.UseWaitCursor = true;
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.zedGraphControl1);
this.splitContainer2.Panel2.UseWaitCursor = true;
this.splitContainer2.Size = new System.Drawing.Size(667,
254);
this.splitContainer2.SplitterDistance = 77;
this.splitContainer2.TabIndex = 0;
this.splitContainer2.UseWaitCursor = true;
//
// splitContainer3
//
this.splitContainer3.Dock =
System.Windows.Forms.DockStyle.Fill;
this.splitContainer3.Location = new
System.Drawing.Point(0, 0);
this.splitContainer3.Name = "splitContainer3";
this.splitContainer3.Orientation =
System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer3.Panel1
//
this.splitContainer3.Panel1.Controls.Add(this.lblMarketid);
this.splitContainer3.Panel1.Controls.Add(this.lblExchangeid);
this.splitContainer3.Panel1.Controls.Add(this.lblSelectionid);
this.splitContainer3.Panel1.Controls.Add(this.lblhorse);
this.splitContainer3.Panel1.UseWaitCursor = true;
//
// splitContainer3.Panel2
//
this.splitContainer3.Panel2.Controls.Add(this.btnBack3);
this.splitContainer3.Panel2.Controls.Add(this.btnBack2);
this.splitContainer3.Panel2.Controls.Add(this.btnBack);
this.splitContainer3.Panel2.Controls.Add(this.lblRunner);
this.splitContainer3.Panel2.Controls.Add(this.btnLay);
this.splitContainer3.Panel2.Controls.Add(this.btnLay2);
this.splitContainer3.Panel2.Controls.Add(this.btnLay3);
this.splitContainer3.Panel2.UseWaitCursor = true;
this.splitContainer3.Size = new System.Drawing.Size(667,
77);
this.splitContainer3.SplitterDistance = 25;
this.splitContainer3.TabIndex = 0;
this.splitContainer3.UseWaitCursor = true;
//
// lblMarketid
//
this.lblMarketid.AutoSize = true;
this.lblMarketid.Location = new System.Drawing.Point(334,
8);
this.lblMarketid.Name = "lblMarketid";
this.lblMarketid.Size = new System.Drawing.Size(35, 13);
this.lblMarketid.TabIndex = 3;
this.lblMarketid.Text = "label1";
this.lblMarketid.UseWaitCursor = true;
//
// lblExchangeid
//
this.lblExchangeid.AutoSize = true;
this.lblExchangeid.Location = new
System.Drawing.Point(247, 8);
this.lblExchangeid.Name = "lblExchangeid";
this.lblExchangeid.Size = new System.Drawing.Size(35, 13);
this.lblExchangeid.TabIndex = 2;
this.lblExchangeid.Text = "label1";
this.lblExchangeid.UseWaitCursor = true;
//
// lblSelectionid
//
this.lblSelectionid.AutoSize = true;
this.lblSelectionid.Location = new
System.Drawing.Point(157, 8);
this.lblSelectionid.Name = "lblSelectionid";
this.lblSelectionid.Size = new System.Drawing.Size(35,
13);
this.lblSelectionid.TabIndex = 1;
this.lblSelectionid.Text = "label1";
this.lblSelectionid.UseWaitCursor = true;
//
// lblhorse
//
this.lblhorse.AutoSize = true;
this.lblhorse.Location = new System.Drawing.Point(43, 8);
this.lblhorse.Name = "lblhorse";
this.lblhorse.Size = new System.Drawing.Size(35, 13);
this.lblhorse.TabIndex = 0;
this.lblhorse.Text = "label1";
this.lblhorse.UseWaitCursor = true;
//
// MarketViewRow
//
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Inherit;
this.BackColor = System.Drawing.Color.White;
this.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.Controls.Add(this.splitContainer1);
this.Name = "MarketViewRow";
this.Padding = new System.Windows.Forms.Padding(2, 0, 2,
2);
this.Size = new System.Drawing.Size(671, 511);
this.UseWaitCursor = true;
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
this.splitContainer2.ResumeLayout(false);
this.splitContainer3.Panel1.ResumeLayout(false);
this.splitContainer3.Panel1.PerformLayout();
this.splitContainer3.Panel2.ResumeLayout(false);
this.splitContainer3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
}