G
Guest
I am trying to create a dynamic control, based on the
System.Windows.Form.Label control. The program compiles with no errors, but
errors out when trying to access this code:
class MyLabels : Label
{
}
public ucTime()
{
InitializeComponent();
BuildLabels();
}
public void BuildLabels()
{
int xLeft = 20;
int xTop = 20;
int xINC = 34;
for (int i = 0; i < 7; i++)
{
MyLabels[] MyDates = new MyLabels[7];
MyDates.Text = "Label " + Convert.ToString(i);
MyDates.Width = 70;
MyDates.Height = 25;
MyDates.BorderStyle = BorderStyle.FixedSingle;
MyDates.Left = xLeft;
MyDates.Top = xTop;
this.Controls.Add(MyDates);
xTop += xINC;
}
}
with this error:
"use the 'new' keyword to create an object instance, and it fails on the
first line where I'm trying to assign the "Text" value.
Any ideas?
Thanks in advance,
System.Windows.Form.Label control. The program compiles with no errors, but
errors out when trying to access this code:
class MyLabels : Label
{
}
public ucTime()
{
InitializeComponent();
BuildLabels();
}
public void BuildLabels()
{
int xLeft = 20;
int xTop = 20;
int xINC = 34;
for (int i = 0; i < 7; i++)
{
MyLabels[] MyDates = new MyLabels[7];
MyDates.Text = "Label " + Convert.ToString(i);
MyDates.Width = 70;
MyDates.Height = 25;
MyDates.BorderStyle = BorderStyle.FixedSingle;
MyDates.Left = xLeft;
MyDates.Top = xTop;
this.Controls.Add(MyDates);
xTop += xINC;
}
}
with this error:
"use the 'new' keyword to create an object instance, and it fails on the
first line where I'm trying to assign the "Text" value.
Any ideas?
Thanks in advance,