Results 1 to 6 of 6

Thread: Creating Controls In A Loop

  1. #1
    Join Date
    Nov 2009
    Posts
    680

    Creating Controls In A Loop

    Hello, I am learning c# programming and now I am working on this and now I want to create one program which will create controls in the loop. If anyone is having idea regarding it, then please provide me solution for that. I am waiting for your reply. If you are having any suggestion then please provide me that.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Creating Controls In A Loop

    Hey, it is so simple to use. I have created below code which will allow you to create it. You need to check it, as I have not tested it.
    Code:
    for (int i = 0 ; I == 63 ; I + +)
                {
                    System.Windows.Forms.Button button + i = new System.Windows.Forms.Button();
                }

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Creating Controls In A Loop

    Hello, if you make use of the code below then you will able to get the solution for the dynamic control creation. So, just use the code below:
    Code:
    or (int J = 0; J < iCtr; J++)
    ans = new HtmlInputText();
    if (one == "0")
    {
    ans.Value =
    ds.Tables["Answers"].Rows[J]["vStudyAText"].ToString).Trim();
    }
    ans.ID = "ans";
    this.Controls.AddAt(this.Controls.IndexOf(PlaceHol der1), ans);
    }

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Creating Controls In A Loop

    Hello, I think you need to use the code below which will create control in a loop. I have tested it, you can make use of it.
    Code:
    int x = 50;
    int y = 50;
    for (int i = 0 ; I <= 63 ; I + +)
                {
                    System.Windows.Forms.Button b = new System.Windows.Forms.Button();
                     b.Name = "Button"+ I.ToString();
                     b.Rentals = new Item(x, y);
                     b.Text = "text button";
                     this.Controls.add(b);
                     y + = 50; / / define
                }

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Creating Controls In A Loop

    Hello, simply make use of the book below and you will able to get the solution for your problem:
    • C-Sharp Language Specification
    • Dissecting a C# Application: Inside SharpDevelop
    • Data Structures and Algorithms with Object-Oriented Design Patterns in C#
    • Sams Teach Yourself C# in 24 Hours

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: Creating Controls In A Loop

    Hello, you need to make use of the following namespace:
    * System
    * System.Web
    * System.Web.UI
    * System.Web.UI.HtmlControls
    * System.Web.UI.WebControls
    * System.Collections
    * System.IO

Similar Threads

  1. Watercooling: Single loop or Dual Loop
    By Akolekar in forum Hardware Peripherals
    Replies: 3
    Last Post: 21-10-2011, 10:52 PM
  2. Reboot Loop in Windows 7 Reboot loop and Safe mode doesn't work
    By mADiRAkSHii in forum Operating Systems
    Replies: 4
    Last Post: 25-01-2011, 07:23 PM
  3. Which is best for iterator: For loop or while loop
    By Leeland in forum Software Development
    Replies: 4
    Last Post: 18-01-2010, 06:03 PM
  4. Differentiate between Do-While loop and While loop
    By REDBULL in forum Software Development
    Replies: 3
    Last Post: 26-11-2009, 10:10 AM
  5. Creating dynamic controls with events
    By Gefry in forum Software Development
    Replies: 3
    Last Post: 11-05-2009, 08:54 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,944,132.70388 seconds with 17 queries