I want to find a TextBox named "textBoxQH_N", where "_N" is a number from 1..96.
So, I have this code:
String sTextBoxToFind = String.Format("textBoxQH{0}", QuarterHour);
TextBox tb = (TextBox)this.Controls.Find(sTextBoxToFind, true);
... but he gave me: "It is not possible to convert the type" System.Windows.Forms.Control [] "to" System.Windows.Forms.TextBox "
So, I changed the second line to capture only the first val returned:
TextBox tb = (TextBox)this.Controls.Find(sTextBoxToFind, true)[0];
What seems to work, but shouldn't the Control Name property be unique to its owner? IOW, Find () should only return 0..1 controls, right?
source
share