不用image,把窗体的底色搞成渐变效果,100分请教!
---------------------------------------------------------------
试试下面的代码,挺有趣的。。。
'form:
Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
DrawGradient(Color.White, Color.Gainsboro, Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal, Me)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DrawGradientString("你好,显示结果是否满意?", Color.Blue, Color.Firebrick,
Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal, Me)
End Sub
'module:
'设置窗体渐变色
Sub DrawGradient(ByVal color1 As Color, ByVal color2 As Color, ByVal mode As System.Drawing.Drawing2D.LinearGradientMode,
ByVal fm As Form)
Dim a As New System.Drawing.Drawing2D.LinearGradientBrush(New RectangleF(0, 0, fm.Width, fm.Height), color1, color2,
mode)
Dim g As Graphics = fm.CreateGraphics
g.FillRectangle(a, New RectangleF(3, 3, fm.Width - 14, fm.Height - 33))
g.Dispose()
End Sub
'添加信息提示并设置字体成渐变色
Sub DrawGradientString(ByVal text As String, ByVal color1 As Color, ByVal color2 As Color, ByVal mode As
System.Drawing.Drawing2D.LinearGradientMode, ByVal fm As Form)
Dim a As New System.Drawing.Drawing2D.LinearGradientBrush(New RectangleF(0, 0, 100, 19), color1, color2, mode)
Dim g As Graphics = fm.CreateGraphics
Dim f As Font
f = New Font("隶书", 26, FontStyle.Bold, GraphicsUnit.World)
g.DrawString(text, f, a, 10, 10)
g.Dispose()
End Sub
---------------------------------------------------------------