top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Implement Parent Form with Colorful Background on Run Time Using Visual Basic .Net?

0 votes
395 views
How to Implement Parent Form with Colorful Background on Run Time Using Visual Basic .Net?
posted Feb 4, 2016 by Sathyasree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

We can Change Color Of GUI by the given property of Form. But these Color Are simple Colors. But with this technique you can make your Gradient Color forms.

We can Change Color Of form by the given property of Form. But these Color Are simple Colors. But with this technique you can make your Gradient Color forms. Because it changes the color of form dynamically you can set the ratio of color at each instance. Follow these Steps

Write these lines code in parent forms load event

For Each MdiCtl As MdiClient In Controls
Dim MdiPainter As New MdiContainer(MdiCtl)
Next
 With Me
      frmChild = New Form2
      frmChild.MdiParent = Me
      frmChild.Show()
     .frmChild.SetDesktopBounds(35,35,.frmChild.Width,rmChild.Height)
 End With

This function infact set form as parent form and set its bound on desktop. Now just make that region.this region code is important please copy it carefully.Handles painting of the MdiClient(ie: the mdiform it's self )

#Region " MdiClient Paint Handling Class " '

Public Class MdiContainer

Inherits Control

Private WithEvents MdiPane As Control

Public Sub New(ByVal ctl As Control)

MdiPane = DirectCast(ctl, Control)

End Sub

Private Sub MdiPane_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MdiPane.Paint

   Dim rect As New Rectangle(0, 0, MdiPane.Width, MdiPane.Height)

   Dim b As New System.Drawing.Drawing2D.LinearGradientBrush(rect, Color.FromArgb(Color.Violet.A, Color.Violet.R, Color.Violet.G, Color.Violet.B), Color.FromArgb(255, 0, 72, 160),

   Drawing2D.LinearGradientMode.Horizontal Or Drawing2D.LinearGradientMode.ForwardDiagonal)

   e.Graphics.FillRectangle(b, rect)

   e.Graphics.Dispose()

  End Sub

End Class
answer Feb 4, 2016 by Shivaranjini
Similar Questions
...