NumericUpDown background colour change for disabled element

前端 未结 3 1409
忘了有多久
忘了有多久 2021-01-21 05:15

On my winform application I\'m trying to do colour-coding on the required fields. On user editing, when a required input is filled in, the background becomes light green, if req

3条回答
  •  长情又很酷
    2021-01-21 06:10

    NumericUpdown is a composite of multiple controls. The textbox is inside the NUD and has a one pixel offset. So you are seeing the textbox' BackColor being set differently from the outer NUD control. The true cause of your problem isn't visible in your snippet but a repro for this behavior is:

            numericUpDown1.BackColor = Color.Red;
            numericUpDown1.Enabled = false;
            numericUpDown1.Controls[1].BackColor = SystemColors.InactiveBorder;
    

    You'll need to fix the code that sets the BackColor of the nested control, whatever it looks like. Probably a foreach on the Controls collection.

提交回复
热议问题