using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text;
using System.Data;
using System.Drawing;
namespace DeviceApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[MTAThread]
static void Main()
{
Application.Run( new Form1() );
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Load += new EventHandler( Form1_Load );
}
void Form1_Load( object sender, EventArgs e )
{
int currY = 10;
int heightOfControl = 30;
for ( int i = 0; i < 10; i++ )
{
ControlCreator cc = new ControlCreator( 10, currY, null );
foreach ( Control c in cc.ControlsToAdd )
{
this.panel1.Controls.Add( c );
}
currY += heightOfControl;
}
}
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.MainMenu mainMenu1;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose( bool disposing )
{
if ( disposing && ( components != null ) )
{
components.Dispose();
}
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 InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panel1
//
this.panel1.Location = new System.Drawing.Point( 3, 3 );
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size( 234, 262 );
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF( 96F, 96F );
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size( 240, 268 );
this.Controls.Add( this.panel1 );
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout( false );
}
#endregion
private System.Windows.Forms.Panel panel1;
}
class ControlCreator
{
private List<Control> controlsToAdd = new List<Control>();
public List<Control> ControlsToAdd { get { return controlsToAdd; } }
public ControlCreator( int baseX, int currentY, DataRow someData )
{
TextBox text = new TextBox();
text.Location = new Point(baseX, currentY);
controlsToAdd.Add(text);
}
}
}