Re: Can I inherit controls from another class at runtime??
- From: "Steve" <Steve@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Jun 2005 02:01:01 -0700
I have a simple form, with a tabcontrol on it, on the first page there is a
button, behind this button is this code:
private void button1_Click(object sender, System.EventArgs e)
{
ProcessAsset ProcAO = new ProcessAsset();
ProcAO.InitializeComponent();
foreach(Control ctTmp in ProcAO.ObjectArray)
{
Control ctObj = new
Control(ctTmp.Text,ctTmp.Left,ctTmp.Top,ctTmp.Width,ctTmp.Height);
ctObj.Visible = true;
this.Page2.Controls.Add(ctObj);
}
tabControl1.SelectedTab = Page2;
}
I have a second .cs file in this solution called ProcessAsset.cs, in there I
have this code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace SWOG
{
public class ProcessAsset
{
public System.Windows.Forms.Label siteLabel;
public System.Windows.Forms.TextBox txtSite;
public System.Windows.Forms.Button btnNext;
public ArrayList ObjectArray = new ArrayList();
public ProcessAsset()
{
InitializeComponent();
ObjectArray.Add(this.siteLabel);
ObjectArray.Add(this.txtSite);
ObjectArray.Add(this.btnNext);
}
public void InitializeComponent()
{
this.siteLabel = new System.Windows.Forms.Label();
this.txtSite = new System.Windows.Forms.TextBox();
this.btnNext = new System.Windows.Forms.Button();
this.siteLabel.Location = new System.Drawing.Point(88, 32);
this.siteLabel.Name = "siteLabel";
this.siteLabel.Size = new System.Drawing.Size(48, 23);
this.siteLabel.TabIndex = 0;
this.siteLabel.Text = "Site";
this.siteLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.siteLabel.Visible = true;
this.txtSite.Location = new System.Drawing.Point(144, 32);
this.txtSite.Name = "txtSite";
this.txtSite.TabIndex = 1;
this.txtSite.Text = "";
this.txtSite.Visible = true;
this.btnNext.Location = new System.Drawing.Point(448, 272);
this.btnNext.Name = "btnNext";
this.btnNext.TabIndex = 2;
this.btnNext.Text = "Next >>";
this.btnNext.Visible = true;
}
}
}
When I click the button on page1 i want the objects created in
ProcessAsset.cs to be created on Page 2. At the moment all that happens is
that the tab changes page.
Thanks
.
- Follow-Ups:
- References:
- Can I inherit controls from another class at runtime??
- From: Steve
- Re: Can I inherit controls from another class at runtime??
- From: Jon Skeet [C# MVP]
- Re: Can I inherit controls from another class at runtime??
- From: Steve
- Re: Can I inherit controls from another class at runtime??
- From: Jon Skeet [C# MVP]
- Can I inherit controls from another class at runtime??
- Prev by Date: Re: CPU Serial Number
- Next by Date: Re: My first impressions of ASP.NET
- Previous by thread: Re: Can I inherit controls from another class at runtime??
- Next by thread: Re: Can I inherit controls from another class at runtime?? SOLVED
- Index(es):