Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Implementing Parent Form with Colorful Background on Run Time Using Visual Basic .Net

Author: Zunnair

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

Article Comments
The code is giving problem. The decleration of frmChild and form2 are not in code.
Where to write the #region code.
#end Region is missing

Posted on 6/11/2010 4:49:14 AM by seshadri sekhar

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Implementing and hiding OverLoaded Delete Functions using Visual Basic.net

Disclaimer - Privacy
© 2002-2017 DevASP.net