Make all Controls on a Form read-only at once

前端 未结 7 489
故里飘歌
故里飘歌 2021-01-12 07:40

Does anyone have a piece of code to make all Controls (or even all TextBoxes) in a Form which is read-only at once without having to set every Control to read-only individua

相关标签:
7条回答
  • 2021-01-12 08:14

    I haven't tested this, but it should work:

    foreach (var textBox in this.Controls.OfType<TextBox>())
        textBox.ReadOnly = true;
    

    Edit: This is not such a good solution it seems: see Timwi's comment.

    0 讨论(0)
提交回复
热议问题