Click here to Skip to main content
15,867,860 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Task 1: I would like to empty several text boxes at once; for this I use an array in which I store the contents of the text boxes. I would then overwrite them with a for loop.

Unfortunately, nothing happens to the contents of the text boxes when the function is executed.

What am I doing wrong?

vc++
array <textbox ^=""> ^textboxes = gcnew array <textbox ^="">(10);
	for (int i = 0; i < 10; i++)
	{

		textboxes[i] = gcnew TextBox();
		textboxes[i]->Text = "...";

	}


Possibly a 2nd question: with this method I can certainly declare input criteria for the text boxes, are there simple methods for this, for example to accept positive numbers with two decimal places?

Many thanks in advance

What I have tried:

Various methodes like defining it in an other way, but this would be definetely the prettiest method to use.
Posted
Updated 25-Apr-22 8:50am
v2
Comments
Richard Deeming 25-Apr-22 11:53am    
You're creating an array of 10 brand-new TextBox objects, which have no connection to any other instance of the TextBox class. Changes you make to those objects will not have any effect on any other TextBox instances.
Manuel Horn 25-Apr-22 12:00pm    
Pity me! How do i create an array reffering to the existing textboxes?
Richard Deeming 25-Apr-22 12:06pm    
textboxes[0] = yourFirstTextBox;
textboxes[1] = yourSecondTextBox;
...
Maciej Los 25-Apr-22 14:50pm    
Sounds like an answer :)
0x01AA 25-Apr-22 15:13pm    
Looks like you posted it in the wrong tree :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900