Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Control not appearing

    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.
    Code:
    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!

  • #2
    Regular Coder
    Join Date
    Dec 2011
    Location
    NW England
    Posts
    194
    Thanks
    8
    Thanked 15 Times in 15 Posts
    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.

  • #3
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,806
    Thanks
    41
    Thanked 199 Times in 198 Posts
    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

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #4
    Regular Coder
    Join Date
    Dec 2011
    Location
    NW England
    Posts
    194
    Thanks
    8
    Thanked 15 Times in 15 Posts
    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)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •