Custom Button Background
-
I hope I'm just missing something basic. Is it possible to have a custom background (say, gradient) for a System.Windows.Forms.Button without having to do *ALL* the drawing yourself. OnPaintBackground does not appear to be called; the paint code for Button appears to be integrated with it's background logic.
-
I hope I'm just missing something basic. Is it possible to have a custom background (say, gradient) for a System.Windows.Forms.Button without having to do *ALL* the drawing yourself. OnPaintBackground does not appear to be called; the paint code for Button appears to be integrated with it's background logic.
I think you should be able to do this without much problem by creating a csutom control which derives from Button class. You can override the OnPaint method and call base.OnPaint() so that it would do all the normal painting required for creating a Button and the you could draw whatever you want, like gradient or ...
--- "Drawing on my superior command of language I said nothing."
-
I think you should be able to do this without much problem by creating a csutom control which derives from Button class. You can override the OnPaint method and call base.OnPaint() so that it would do all the normal painting required for creating a Button and the you could draw whatever you want, like gradient or ...
--- "Drawing on my superior command of language I said nothing."
That solution will not let you paint the background and ignore the foreground. The need is to have a custom background, but let .NET draw the foreground image and text. The calculations of *where* the image and text appear is fairly convoluted due to the ImageAlign, TextAlign, and TextImageRelation properties. I have pretty much confirmed this is not possible as .NET draws the button background and image/text in one operation, giving derived classes no opportunity to inject in the process. Thank you for the answer.
-
That solution will not let you paint the background and ignore the foreground. The need is to have a custom background, but let .NET draw the foreground image and text. The calculations of *where* the image and text appear is fairly convoluted due to the ImageAlign, TextAlign, and TextImageRelation properties. I have pretty much confirmed this is not possible as .NET draws the button background and image/text in one operation, giving derived classes no opportunity to inject in the process. Thank you for the answer.
Can't you set a picture as the background of a button? and have another picture for the foreground, and text and all that other stuff? Or is it I that is confused?