NumericUpDown backcolor not working as expected

后端 未结 3 1779
我在风中等你
我在风中等你 2021-01-23 02:53

I recently had the need to write a version of the Windows NumericUpDown control which could highlight whether a value was mandatory. It needed to do this by changing the back co

3条回答
  •  滥情空心
    2021-01-23 03:56

    The above method did not work out for me. My workaround was:

        private void smartRefresh()
        {
            if (oldBackColor != BackColor) {
                oldBackColor = BackColor;
                Hide();
                Application.DoEvents();
                Show();
                Application.DoEvents();
            }
        }
    

    With a private member oldBackColor.

    Now it always shows correctly but does not flicker.

    Addendum: I think some part of the Control doesn't get painted at all (I consider it a bug) as the "mispainted" bos around it is not uniformly colored an somtimes traces of the window that was there before can be seen.

提交回复
热议问题