Results 1 to 9 of 9

Thread: Background image in a Form in VB.NET

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2003
    Location
    Portugal
    Posts
    49

    Background image in a Form in VB.NET

    Can someone tell me how to put a background image in a Form in VB.NET?

    I used a PictureBox, but is it possible to put an image in a Form without it ?

    I tried using the "Background Image" property of the Form, but the problem is that the form has another property called "Backcolor" that puts an "opaque" color (it doesn´t let me put the value "transparent" in a Form) and so it hides the image.


  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I don't understand your problem.

    All forms have a backcolor property. But it is irrelevant when you set the BackGroundImage to anything other than Nothing.

    Start a new Windows Application, set the BackgroundImage to an image on your computer. Run the application. It works AS IS.

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2003
    Location
    Portugal
    Posts
    49
    I did that several times, and i did it once more.

    When i run the app, the Form only appears with the default color of the Backcolor property, no Image appears.

    I'm using VS.NET 2002.


  4. #4
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    I agree with nemaroller.

    Can you zip up the project you created (just the one form with the background image) and post it? I'm also running 2002 and I'll let you know what happens when I run it on my PC.
    This world is not my home. I'm just passing through.

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2003
    Location
    Portugal
    Posts
    49
    i did it now with an empty form... but with my app no



    ...and the properties of the two forms are equal...what a heck ?!

  6. #6

    Thread Starter
    Member
    Join Date
    Oct 2003
    Location
    Portugal
    Posts
    49
    it's unbealivable...

    sometimes it does and others don't ... actually it only give me once

  7. #7
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    If you want to let me see a copy of your "empty" project I'll see if I can spot something. Otherwise, I don't think I can help.
    This world is not my home. I'm just passing through.

  8. #8

    Thread Starter
    Member
    Join Date
    Oct 2003
    Location
    Portugal
    Posts
    49
    Ok i finally got the Microsoft logic for the "beast"...

    ...it's unbealivable, but ...well... whatever...it's Microsoft you know !?

    Well here it is, when i change the BackgroundImage property of any control (Forms, Buttons,...) i have to do the "Save All" to the Project, for him to update the value of the BackgroundImage property.

    If i don´t make the "Save All", the value of the BackgroundImage property stays always with the old value.

    UUUUUUUUUUnbealivable ....but it works now

    Many thanks anyway trisuglow, but it finally works.

  9. #9

    Thread Starter
    Member
    Join Date
    Oct 2003
    Location
    Portugal
    Posts
    49
    Here it is, the damn code (but with no "Save All"):



    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

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Bitmap)
    Me.ClientSize = New System.Drawing.Size(792, 566)
    Me.Name = "Form1"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
    Me.Text = "Form1"

    End Sub

    #End Region

    End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width