-
March 1st, 2011, 07:16 PM
#1
[Q] Issue with (RichTextBox)this.Controls[...];
As part of a larger project, on one form I have several rich text box controls. I am trying to access them all in the following for loop.
for (int i = 0; i < 7; i++)
{
RichTextBox txtbx = (RichTextBox)this.Controls["txtbx" + ((lanterntypes)i).ToString()];
string[] lines = new string[4];
lines[0] = "goodbye";
for (int i2 = 1; i2 <= 3; i2++)
{
lines[i2] = "hello";
}
txtbx.Lines = lines;
}
However, txtbx returns as null for every iteration.
lanterntypes is an enum, of which the first is ParCan, and I have a rich text box called txtbxParCan so I don't think there is a problem with the names in fact being different.
I've used this method before in this same project succesfully with labels, so any help as to what I'm doing wrong now would be gratefully received.
Cheers to anyone who can help!
Tam
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|