Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2008 .NET Window
How to set a Window properties or code, to open window form to right side of screen and full size from top to bottom and little less whatever i want.
Can anybody help me to resolve this problem.
Posted 17-Sep-12 21:15pm
Namit KB1.3K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Set the StartPosition property to Manual. Use the Load event to change the position, the earliest you'll know the actual size of the window:
 
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        this.StartPosition = FormStartPosition.Manual;
    }
 
    private void Form1_Load(object sender, EventArgs e)
    {
        Screen scr = Screen.FromPoint(this.Location);
        this.Location = new Point(scr.WorkingArea.Right - this.Width, scr.WorkingArea.Top);
    }
}
 
Cheers
  Permalink  
v3
Comments
Namit KB at 18-Sep-12 4:22am
   
Thanks for your help, but what is this working area its giving me error...
 
Error8 : 'object' does not contain a definition for 'WorkingArea' and no extension method 'WorkingArea' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Mario Majčica at 18-Sep-12 4:24am
   
Sorry, check the edit, my copy paste error. I tried the code above and it is working properly.
 
Cheers
Namit KB at 18-Sep-12 4:28am
   
Oh...i solved this...through your help thank u..but its coming..Like top----right, it is better if i will get middle ---right
Mario Majčica at 18-Sep-12 4:31am
   
Then modify the location in this way:
 
this.Location = new Point(scr.WorkingArea.Right / 2, scr.WorkingArea.Top);
 
It is a simple calculation, WorkingArea gives you the screen positions, and with that you can calculate the point where you want to show your form.
 
Cheers
Namit KB at 18-Sep-12 4:43am
   
Thanks for ur help..But still its coming in top---right and not coming in middle---right.
Mario Majčica at 18-Sep-12 4:44am
   
You had just asked that: "it is better if i will get middle ---right". Can you explain exactly where and how you would like to put this form on the screen??? Make a picture and post the link! :)
 
Cheers
Namit KB at 18-Sep-12 5:00am
   
Please visit the link :-- "www.sendspace.com/file/wejhpi"
Mario Majčica at 18-Sep-12 5:09am
   
Try with this:
 

this.Location = new Point(scr.WorkingArea.Right - this.Width, (scr.WorkingArea.Bottom - this.Height) / 2);
 
And don't forget to accept and vote the answer ;)
 
Cheers
Namit KB at 18-Sep-12 5:30am
   
Thanks a lot, it works as i was looking...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 370
1 Prakriti Goyal 177
2 Sergey Alexandrovich Kryukov 155
3 jlopez788 134
4 _Amy 110
0 OriginalGriff 6,762
1 Sergey Alexandrovich Kryukov 5,539
2 Maciej Los 3,479
3 Peter Leow 3,323
4 DamithSL 2,505


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 18 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100