Does anyone know how to make the control highlighting like in microsoft paint? Backlight

Those. Initially, as I understand it, the tool has a background color. And when you point at it with the mouse, the background brightens a bit. And below the brightness increases more than the top

  • As I understand it, this is not a background highlighting but a replacement. Those. You should have 3 backgrounds: the passive element, the active element, the element under the cursor. Well, switch them accordingly - rdorn
  • @rdorn, yes, it is clear that a replacement. It’s just that the background is brighter from below than from above, regardless of the position of the cursor on this controller - Valeriy
  • one
    This is called a gradient fill. In WinForms, you need to do it with your hands, or take a ready-made texture and substitute it. But this is clearly done by the textural background and not by the color. - rdorn
  • @rdorn, okay, thanks - Valeriy
  • Then make out in the form of an answer - rdorn

1 answer 1

The effect you are asking for is called a gradient - a smooth transition from one color to another. By simply changing the background color, this effect cannot be achieved.

In WinForms, there are no ready-made tools to get a gradient, but you can instead substitute a suitable texture as a background image.

Thus, the task is reduced to obtaining the desired texture, and for this you can either manually paint a Bitmap as you like, or prepare the texture in advance in a convenient graphic editor.

If a strictly vertical or strictly horizontal gradient is required, then the size of the texture can be 1 * n or n * 1 pixels, respectively. n selected to obtain the desired smoothness of the gradient.

To get the effect, you need to set the necessary texture in the Control.BackgroundImage property and set the necessary value for background scaling in the Control.BackgroundImageLayout property, for example Stretch for textures of size 1 * n or n * 1 .

  • Thanks for the detailed response - Valeriy