I wish to assign values to NumericUpDowns which are named numericUpDown1
, numericUpDown2
, etc. What I wish to achieve is something like this:
for (int i = 0; i < readBuf.Length; i++)
{
numericUpDown[i + 1].Value = Convert.ToDecimal(BitConverter.ToSingle(readBuf[i], startIndex: 0));
}
What I tried doing is the method described here: Loop through Textboxes, but it doesn't give the expected results when I use it like this
var allNumUpDwn = this.GetChildControls<NumericUpDown>();
int i = 0;
foreach (NumericUpDown nud in allNumUpDwn)
{
nud.Value = Convert.ToDecimal(BitConverter.ToSingle(readBuf[i], startIndex: 0));
i++;
}