|
I Define a user control that Inherits From Control Class
I want to show many instances of that class in a new class than inherits from Pannel Class
When I make instances and run this Code, there is no control in my Pannel:
This.Controls.add(new...);
modified 12-Jan-13 2:44am.
|
|
|
|
|
Without seeing the rest of the code, it's impossible to answer the question accurately.
Though, chances are good that you didn't set the Location property of any of the controls you created and they're all sitting on top of one another in the upper left corner of the panel.
|
|
|
|
|
Thankss a lot
this is the entire code:
public Mine[,] Mines;
public void Start()
{
this.Controls.Clear();
int counter = this.Bombs;
Mines= new Mine[Rows, Columns];
for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Columns; j++)
{
Mines[i, j] = new Mine()
{
IsColored = true,
IsHidden = true,
Location = new System.Drawing.Point(j*16,i*16)
};
this.Controls.Add(Mines[i, j]);
}
}
}
|
|
|
|
|
Two things you need to do: First, try setting a Size for each Mine: 10x10 will probably help.
Second, how are you sure that they aren't being added? Try setting a BorderStyle as well:
for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Columns; j++)
{
Mines[i, j] = new Mine()
{
IsColored = true,
IsHidden = true,
Location = new System.Drawing.Point(j * 16, i * 16),
Size = new Size(10,10),
BorderStyle = BorderStyle.FixedSingle
};
this.Controls.Add(Mines[i, j]);
}
}
See if you can see them then.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|