I have a form and I want to loop through all the textboxes on my form and align the text to the center.
This is the code I have used:
for (int i = 0; i < this.Controls.Count; i++)
{
if (this.Controls is TextBox)
{
((TextBox)(this.Controls)).TextAlign =
HorizontalAlignment.Center;
}
}
A similar method has worked to assign a function to each textbox for onExit.
No problems are picked up on this, and the solution runs, but the text isn't aligned!
Any help would be appreciated.
This is the code I have used:
for (int i = 0; i < this.Controls.Count; i++)
{
if (this.Controls is TextBox)
{
((TextBox)(this.Controls)).TextAlign =
HorizontalAlignment.Center;
}
}
A similar method has worked to assign a function to each textbox for onExit.
No problems are picked up on this, and the solution runs, but the text isn't aligned!
Any help would be appreciated.