I see this control uses Label and PictureBox to show "Title" and Image. The Title and Image show as transparent on Gradient background.
|
Actually it does not use an image or label. These are rendered onto the control in the OnPaint of the control.
I still would like to use the gradient header, but need to find out how to make label and picture transparent.
Whenever you set a label or any other controls background to "Transparent" it will take the are on which is resides in its parent as the background....however, the GradientFormHeader control is not a parent control which means that no child object actually resides within the control itself. So the labels parent is the form or container it resides within.
You have a couple of options. First, just render your text on the gradient form header. Handle the Paint event of the GradientFormHeader and just add your logic to render on top of it. Second option would be to handle the Paint event of the label and capture the background of the rendered GradientFormHeader using the DrawToBitmap or the ScreenCapture classes...either way will work. And then create your own transparency....this is ultimately what happens natively anyway.
The example above may be the approach you want to take. I just created a new class, inherited from GradientFormHeader, overwrote the OnPaint method and added my logic. You could create property that you set that adds this text to your header. Below is the OnPaint code for the above example:
Public Class CustomHeader
Inherits MicroFour.StrataFrame.UI.Windows.Forms.GradientFormHeader
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
e.Graphics.DrawString("My Custom Text", Me.Font, Drawing.Brushes.Red, 200, 10)
End Sub
End Class