Results 1 to 4 of 4

Thread: Query Regarding Visual Basic.Net Forms

  1. #1
    Join Date
    Jan 2009
    Posts
    69

    Query Regarding Visual Basic.Net Forms

    I am not a programmer in visual basic.net. I am having a small query in this language. can anyone help me in finding the solution regarding as how can i change the background color of all the forms in vb.net?

    Please provide some help regarding this

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Query Regarding Visual Basic.Net Forms

    Code:
    Imports System
    Imports System.Collections
    Imports System.Data
    Imports System.IO
    Imports System.Xml.Serialization
    Imports System.Windows.Forms
    Imports System.Drawing
    Imports System.Drawing.Drawing2D
    Imports System.Drawing.Text
    Imports System.Drawing.Printing
    
    Public Class MainClass
        Shared Sub Main()
           Dim form1 As Form = New Form1()
           Application.Run(form1) 
        End Sub
    End Class
    
    Public Class Form1
        Inherits System.Windows.Forms.Form
    #Region " Windows Form Designer generated code "
        Public Sub New()
            MyBase.New()
            'This call is required by the Windows Form Designer.
            InitializeComponent()
            'Add any initialization after the InitializeComponent() call
        End Sub
        'Form overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub
        Friend WithEvents btnColor As System.Windows.Forms.Button
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.Container
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.btnColor = New System.Windows.Forms.Button()
            Me.SuspendLayout()
            '
            'btnColor
            '
            Me.btnColor.Location = New System.Drawing.Point(54, 192)
            Me.btnColor.Name = "btnColor"
            Me.btnColor.Size = New System.Drawing.Size(184, 48)
            Me.btnColor.TabIndex = 0
            Me.btnColor.Text = "Change background color"
            '
            'Form1
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
            Me.ClientSize = New System.Drawing.Size(292, 268)
            Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnColor})
            Me.Name = "Form1"
            Me.Text = "Color Dialog Example"
            Me.ResumeLayout(False)
    
        End Sub
    
    #End Region
    
        Private Sub btnColor_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnColor.Click
            Dim myDialog As New ColorDialog()
            Dim Temp As Color = btnColor.BackColor
            If myDialog.ShowDialog() = DialogResult.OK Then
                Me.BackColor = myDialog.Color
                btnColor.BackColor = Temp
            End If
        End Sub
    End Class

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Query Regarding Visual Basic.Net Forms

    Code:
    foreach (Control ctl in this.Controls)
    {
       try
       {
          // Attempt to cast the control to type MdiClient.
          ctlMDI = (MdiClient) ctl;
    
          // Set the BackColor of the MdiClient control.
          ctlMDI.BackColor = this.BackColor;
       }
       catch (InvalidCastException exc)
       {
          // Catch and ignore the error if casting failed.
       }		         
    }
    		
    // Display a child form to show this is still an MDI application.
    Form2 frm = new Form2();
    frm.MdiParent = this;
    frm.Show();

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Query Regarding Visual Basic.Net Forms

    Code:
    'Set the new color
    My.Settings.BGColor = MyDialog.Color
    'Save the settings (so they're persisted)
    My.Settings.Save()
    hat line will need to be added to each form when it loads. Unfortunately, unless I have missed something, there isn't a way to set all the forms in a nice single statement, each has to be set manually.

Similar Threads

  1. Query on submitting forms using ASP
    By Bindusar in forum Software Development
    Replies: 3
    Last Post: 25-11-2009, 09:42 PM
  2. Basic query, using zone alarm
    By ADAHY in forum Software Development
    Replies: 3
    Last Post: 29-10-2009, 03:10 PM
  3. Query Regarding Visual Basic.Net
    By Renderman21 in forum Software Development
    Replies: 4
    Last Post: 20-03-2009, 02:49 PM
  4. Visual Basic 2005 or Visual Basic 6
    By Aasha in forum Software Development
    Replies: 5
    Last Post: 15-01-2009, 06:56 PM
  5. Visual Basic on LAN
    By djbbenn in forum Software Development
    Replies: 2
    Last Post: 05-08-2008, 02:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,018,886.42654 seconds with 17 queries