Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

1 solution

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:

C#
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
 
Share this answer
 
v3
Comments
Namit KB 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 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 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 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 18-Sep-12 4:43am    
Thanks for ur help..But still its coming in top---right and not coming in middle---right.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900