dynamic objects

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert

    dynamic objects

    I need to be able to get 20 of the same Label object named sequentialy right
    on top of each other.
    What is the best way to do this here is my code
    --Robbie
    using System;
    using System.Drawing;
    using System.Collecti ons;
    using System.Componen tModel;
    using System.Windows. Forms;
    using System.Data;
    namespace post
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows. Forms.Form
    {
    private System.Windows. Forms.Label label1;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.Componen tModel.Containe r components = null;
    public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeCompo nent();
    }
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null)
    {
    components.Disp ose();
    }
    }
    base.Dispose( disposing );
    }
    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeCompo nent()
    {
    this.label1 = new System.Windows. Forms.Label();
    this.SuspendLay out();
    //
    // label1
    //
    this.label1.Loc ation = new System.Drawing. Point(64, 56);
    this.label1.Nam e = "label1";
    this.label1.Tab Index = 0;
    this.label1.Tex t = "label1";
    //
    // Form1
    //
    this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
    this.ClientSize = new System.Drawing. Size(292, 266);
    this.Controls.A dd(this.label1) ;
    this.Name = "Form1";
    this.Text = "Form1";
    this.ResumeLayo ut(false);
    }
    #endregion
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
    Application.Run (new Form1());
    }
    }
    }


  • Jon Skeet

    #2
    Re: dynamic objects

    Robert <robertchan1@ho tmail.com> wrote:[color=blue]
    > I need to be able to get 20 of the same Label object named sequentialy right
    > on top of each other.
    > What is the best way to do this here is my code[/color]

    I'd suggest using an array. Even if the object's names need to be
    sequential, that doesn't mean you have to have variables label1, label2
    etc - just an array of two Label references would do.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Robert Chan

      #3
      Re: dynamic objects

      ok can you exemplify that.
      I am used to JavaScript arrays but I have never done them in C#, also what
      about setting up a class to create the array.

      --Robbie


      Comment

      • Jon Skeet

        #4
        Re: dynamic objects

        Robert Chan <robertchan1@ho tmail.com> wrote:[color=blue]
        > ok can you exemplify that.
        > I am used to JavaScript arrays but I have never done them in C#, also what
        > about setting up a class to create the array.[/color]

        I suggest you start with a C# tutorial, and preferrably completely
        avoid GUIs for the moment - learn the basics in console applications,
        and you'll find it much easier to move onto GUIs once you've done that.

        --
        Jon Skeet - <skeet@pobox.co m>
        Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

        If replying to the group, please do not mail me too

        Comment

        Working...