Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , ,

Sponsored Links



Creating Controls In A Loop

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 05-02-2010
technika's Avatar
Member
 
Join Date: Nov 2009
Posts: 688
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.
Reply With Quote
  #2  
Old 05-02-2010
opaper's Avatar
Member
 
Join Date: May 2008
Posts: 2,362
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();
            }
Reply With Quote
  #3  
Old 05-02-2010
MindSpace's Avatar
Member
 
Join Date: Feb 2008
Posts: 1,832
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);
}
Reply With Quote
  #4  
Old 05-02-2010
Modifier's Avatar
Member
 
Join Date: Jan 2008
Posts: 1,502
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
            }
Reply With Quote
  #5  
Old 05-02-2010
Praetor's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,937
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
Reply With Quote
  #6  
Old 05-02-2010
Member
 
Join Date: May 2008
Posts: 1,990
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Creating Controls In A Loop"
Thread Thread Starter Forum Replies Last Post
Watercooling: Single loop or Dual Loop Akolekar Hardware Peripherals 3 21-10-2011 11:52 PM
Reboot Loop in Windows 7 Reboot loop and Safe mode doesn't work mADiRAkSHii Operating Systems 4 25-01-2011 07:23 PM
Which is best for iterator: For loop or while loop Leeland Software Development 4 18-01-2010 06:03 PM
Differentiate between Do-While loop and While loop REDBULL Software Development 3 26-11-2009 10:10 AM
Creating dynamic controls with events Gefry Software Development 3 11-05-2009 09:54 PM


All times are GMT +5.5. The time now is 11:58 AM.