I have a
VB.NET 2003 program that exhibits a strange TextBox behaviour. The program has a Panel control "mpnlGridInit", that contains a rectangular array of TextBoxes. The TextBoxes are created by row within the array, so that their Item Number within the Panels Controls Collection varies from 0 up to the total number of TextBoxes less 1. When I want to put some String data into a particular TextBox, identified by its row and column number within the array, I use code like the snippet that follows:
intGridIdx = intRowIdx * 9 + intColIdx
txtCur = CType(mpnlGridInit.Controls.Item(intGridIdx), TextBox)
txtCur.Text = strCellVal
The variable "intGridIdx ", which is the TextBox's Item Number within the Control Collection, is computed from the row and column numbers. The TextBox "txtCur" is then identified, using its Item Number within the Controls Collection of the Panel. Finally, the String "strCellVal" is assigned to the Text property of the TextBox "txtCur". This assignment triggers a TextChanged Event that validates the String "strCellVal".
So far so good. In one section of the program, the above code works perfectly. However, in another section of the program, this code fails. Using Debug I noticed that when the code works, the TextBox's Visible property is "True", while when it fails, the TextBox's Visible property is "False". Apparently, the TextBox gets locked in some way that prevents text being entered.
I tried changing the Visible property to "True" while in Debug, but it was immediately changed back to "False". I am at my wits end over this behaviour.
Any ideas would be gratefully accepted.
Jim.