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. Place form 10px from right side of screen.

Place form 10px from right side of screen.

Scheduled Pinned Locked Moved C#
tutorialquestion
4 Posts 3 Posters 0 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.
  • J Offline
    J Offline
    jafingi
    wrote on last edited by
    #1

    Hi, I want to place my windows form 10 pixels from the right side of my user's screen. But they have different screen resolutions, so i cant place it with a value in pixels. So do anyone know how to do it? I'm using this code on my form-load, to place the window: this.Height = 175; this.Location = new Point(0, Screen.PrimaryScreen.WorkingArea.Height - this.Height); Thanks, Elias Sorensen

    H L J 3 Replies Last reply
    0
    • J jafingi

      Hi, I want to place my windows form 10 pixels from the right side of my user's screen. But they have different screen resolutions, so i cant place it with a value in pixels. So do anyone know how to do it? I'm using this code on my form-load, to place the window: this.Height = 175; this.Location = new Point(0, Screen.PrimaryScreen.WorkingArea.Height - this.Height); Thanks, Elias Sorensen

      H Offline
      H Offline
      Hessam Jalali
      wrote on last edited by
      #2

      int distanceFromRight=10; int distanceFromBottom=10; int screenWidth=Screen.PrimaryScreen.WorkingArea.Width; int screenHeight = Screen.PrimaryScreen.WorkingArea.Height; this.Left = screenWidth - this.Width - distanceFromRight; this.Top=screenHeight-this.Height-distanceFromBottom; or you can use int x = screenWidth - this.Width - distanceFromRight; int y= screenHeight-this.Height-distanceFromBottom; this.SetBounds(x,y,this.Width,this.Height);

      1 Reply Last reply
      0
      • J jafingi

        Hi, I want to place my windows form 10 pixels from the right side of my user's screen. But they have different screen resolutions, so i cant place it with a value in pixels. So do anyone know how to do it? I'm using this code on my form-load, to place the window: this.Height = 175; this.Location = new Point(0, Screen.PrimaryScreen.WorkingArea.Height - this.Height); Thanks, Elias Sorensen

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, your code is placing the window at the bottom end of the screen, but flush left since you specified zero for X. you could replace that zero by an expression that is basically the same as you did for Y, substituting widths for heights of course. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


        1 Reply Last reply
        0
        • J jafingi

          Hi, I want to place my windows form 10 pixels from the right side of my user's screen. But they have different screen resolutions, so i cant place it with a value in pixels. So do anyone know how to do it? I'm using this code on my form-load, to place the window: this.Height = 175; this.Location = new Point(0, Screen.PrimaryScreen.WorkingArea.Height - this.Height); Thanks, Elias Sorensen

          J Offline
          J Offline
          jafingi
          wrote on last edited by
          #4

          Thanks to all. It works perfect now :)

          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