How to change the font color of a disabled TextBox?

后端 未结 9 642
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 05:13

Does anyone know which property sets the text color for disabled control? I have to display some text in a disabled TextBox and I want to set its color to blac

9条回答
  •  执念已碎
    2020-11-27 06:06

    Additionally, in order for ForeColor to be obeyed on a TextBox marked ReadOnly, you must explicitly set the BackColor. If you want to have it still use the default BackColor, you have to make the set explicit, as the designer is too smart for its own good here. It is sufficient to set the BackColor to its current value. I do this in the Load event for the form, like so:

    private void FormFoo_Load(...) {
        txtFoo.BackColor = txtFoo.BackColor;
    }
    

提交回复
热议问题