...

View Full Version : Control not appearing



Sleeping_Troll
01-18-2012, 04:11 PM
When I click the button, I expect a new "Orb" control to appear. "Orb" is a user control which inherits "PictureBox" and has a few additional properties, in fact I have substituted "PictureBox" for "Orb" with the same results... no control appears.

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Orbs;
namespace Begy_Modeler
{
public partial class MainForm : Form
{
public Control[] Particles = new Control[200];
public int n = 0;
public MainForm()
{
InitializeComponent();
}
public void CreateParticle()
{
if(n<200)
{
Particles[n] = new Orb
{
Top = 10,
Left = 10,
BackColor = Color.Blue,
Visible = true
};
Particles[n].Show();
n++;
}
}
void ToolStripButton1Click(object sender, EventArgs e)
{
CreateParticle();
}
}
}
}

Please help me find what stupid little error is causing my head pains!

melloorr
01-18-2012, 05:46 PM
What actually happens when you click the button?

Also, it looks like your trying to use a loop, so it should be a while statement, not an if statement.

alykins
01-18-2012, 07:56 PM
I do not think the end goal there is a loop- I think the end goal there is to limit the amount of created objects to 200 (well logically set up it is @ 199 objects)- if n = 200 there is nothing that happens in the rest of that function- changing to a while loop will make it so when you do create an object you make 199 of them... melloorr does pose a good question though- what is happening? Are you seeing at least one of them? look at your function to create it- they will keep stacking on top of one another over and over and over again. I don't see anything that would tell it to offset WRT other objects

melloorr
01-18-2012, 09:21 PM
True, I didn't notice that. From his first post, it sounds as if nothing is happening. And I couldn't really see anything wrong with his code, so it would be a problem with Orbs (If nothing at all is happening)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum