我希望賦值給其命名爲numericUpDown1
我希望實現NumericUpDowns,numericUpDown2
等是這樣的:遍歷順序控制名稱C#
for (int i = 0; i < readBuf.Length; i++)
{
numericUpDown[i + 1].Value = Convert.ToDecimal(BitConverter.ToSingle(readBuf[i], startIndex: 0));
}
我試圖做的是所描述的方法在這裏:Loop through Textboxes,但它並沒有產生預期的結果,當我使用它像這樣
var allNumUpDwn = this.GetChildControls<NumericUpDown>();
int i = 0;
foreach (NumericUpDown nud in allNumUpDwn)
{
nud.Value = Convert.ToDecimal(BitConverter.ToSingle(readBuf[i], startIndex: 0));
i++;
}
readBuf究竟是什麼?你必須調試你的應用程序。在代碼中插入斷點並查看發生了什麼。 – Dmitry
@Dmitry我正在從另一個進程讀取內存,並使用numericUpDown控件更改它,但有時值會在程序中更改,並且numericUpDowns不會更新,因此我需要再次讀取內存。 –