Creating an array of textboxes at runtime.

haroldjclements

Freshman
Joined
Jun 13, 2004
Messages
46
Hello All,

I have created an application that reads items from a database. What I want to do now is create an array of text boxes that are populated with the data retrieved from the database.

The problem is that I am unsure how to create an array of textboxes at runtime. I can use the .set_Size() method to place the box.

So far I have:

Code:
System.Windows.Forms.TextBox [] tbxResults = new TextBox[20];

while (myDataReader.Read())
{
			
	tbxResults[loopControl] = new TextBox();
	tbxResults[loopControl].set_Location(new System.Drawing.Point(8, y));
	tbxResults[loopControl].set_Visible(true);
				
	loopControl ++;
	y += 24;
}

However the does not work.

Any help will be most appreciated
Harold Clements
 
Back
Top