?
Solved

How can I anchor a windows form?

Posted on 2004-04-07
9
Medium Priority
?
226 Views
Last Modified: 2010-04-15
I’m looking at different ways of anchoring a custom shaped windows form to the right side of the screen. As well, the form should fill the height of the screen but be approximately 230 pixels across.
Can someone give me some code that would auto-stretch the window to the height of the screen, but still be able to define the width?
0
Comment
Question by:mpozzan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 10780846
Do you mean this?

        private void Form1_Load(object sender, System.EventArgs e)
        {
            int nWidth = 230;

            this.Top = 0;
            this.Height = SystemInformation.PrimaryMonitorSize.Height;

            this.Left = (SystemInformation.PrimaryMonitorSize.Width - nWidth)/2;
            this.Width = nWidth;
        }
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 10781439
Just a remark to the post of Alex:

instead
this.Left = (SystemInformation.PrimaryMonitorSize.Width - nWidth)/2;

use

this.Left = SystemInformation.PrimaryMonitorSize.Width - nWidth;
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10781458
Right. I thinked he wants form in the center.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:mpozzan
ID: 10783768
I do want the form on the right of the screen
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 2000 total points
ID: 10783783
Well, the code above with my correction is for the right of the screen.
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 10784503
Upps, a little bit unfair to Alex
0
 

Author Comment

by:mpozzan
ID: 10784508
the following code, does not achor the windows form to the right side of the screen.
As well, it appears in the centre of the screen
private void Form1_Load(object sender, System.EventArgs e)
        {
            int nWidth = 230;

            this.Top = 0;
            this.Height = SystemInformation.PrimaryMonitorSize.Height;

            this.Left = SystemInformation.PrimaryMonitorSize.Width - nWidth;
            this.Width = nWidth;
        }
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 10784523
You should set the start position of the form to Manual
0
 

Author Comment

by:mpozzan
ID: 10784530
sounds good. thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question