Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Size problem

Size problem

Scheduled Pinned Locked Moved C#
helptutorialquestion
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Phoen25
    wrote on last edited by
    #1

    Hello People, may be you can help me with this: I've a winform with FormBorderStyle.None, and I want to set a background image. I want to use the image size as the winform size. The problem is when I run the example, the size of the form is bigger than the image size, so I see a part of the winform with the background color. Here is the code: public FrmOne() { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.Manual; this.BackgroundImage = global::Project1.Properties.Resources.img_1; this.Size = this.BackgroundImage.Size; // not work //this.ClientSize = this.BackgroundImage.Size; // not work this.StartPosition = FormStartPosition.CenterScreen; //int x = Screen.PrimaryScreen.WorkingArea.Width - this.Width ; //int y = Screen.PrimaryScreen.WorkingArea.Height - this.Height ; //this.Location = new Point(x, y); this.tmrTimer.Start(); } Any ideas? Thanks a lot !!!

    P A 2 Replies Last reply
    0
    • P Phoen25

      Hello People, may be you can help me with this: I've a winform with FormBorderStyle.None, and I want to set a background image. I want to use the image size as the winform size. The problem is when I run the example, the size of the form is bigger than the image size, so I see a part of the winform with the background color. Here is the code: public FrmOne() { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.Manual; this.BackgroundImage = global::Project1.Properties.Resources.img_1; this.Size = this.BackgroundImage.Size; // not work //this.ClientSize = this.BackgroundImage.Size; // not work this.StartPosition = FormStartPosition.CenterScreen; //int x = Screen.PrimaryScreen.WorkingArea.Width - this.Width ; //int y = Screen.PrimaryScreen.WorkingArea.Height - this.Height ; //this.Location = new Point(x, y); this.tmrTimer.Start(); } Any ideas? Thanks a lot !!!

      P Offline
      P Offline
      Phoen25
      wrote on last edited by
      #2

      I'm using VS 2005

      1 Reply Last reply
      0
      • P Phoen25

        Hello People, may be you can help me with this: I've a winform with FormBorderStyle.None, and I want to set a background image. I want to use the image size as the winform size. The problem is when I run the example, the size of the form is bigger than the image size, so I see a part of the winform with the background color. Here is the code: public FrmOne() { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.Manual; this.BackgroundImage = global::Project1.Properties.Resources.img_1; this.Size = this.BackgroundImage.Size; // not work //this.ClientSize = this.BackgroundImage.Size; // not work this.StartPosition = FormStartPosition.CenterScreen; //int x = Screen.PrimaryScreen.WorkingArea.Width - this.Width ; //int y = Screen.PrimaryScreen.WorkingArea.Height - this.Height ; //this.Location = new Point(x, y); this.tmrTimer.Start(); } Any ideas? Thanks a lot !!!

        A Offline
        A Offline
        Alexander Wiseman
        wrote on last edited by
        #3

        Hello, It looks like you are placing the size change code inside the constructor for the form. I'm not quite sure why that isn't working, but in an application I am working on, I have initial resizing done inside the Load event handler and it works perfectly. Try putting your sizing code inside the Load event handler instead and see if that works out. For example:

        private void FrmOne_Load(object sender, System.EventArgs e)
        {
        ...
        this.BackgroundImage = global::Project1.Properties.Resources.img_1;
        this.ClientSize = this.BackgroundImage.Size;
        ...
        }

        Hope that helps! Sincerely, Alexander Wiseman

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups