473,322 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Positioning a Window

I am creating a System.Windows.Forms.Form derived form in an OnClick()
method of a button. I would like to set the position of this new form on
the window, but I can't figure out what method to call or property to set to
override where the Operating System places the window. Any brillian ideas
our there?

Thanks
Nov 13 '06 #1
3 1098
You mean like this?

This snippet should be placed in your new form. It will set the left and top
position of this new form 50 pixels
below and to the right of the parent form.

this.Left = this.Owner.Left + 50;
this.Top = this.Owner.Top + 50;

Hope you can use it.
"Matthew Ireland" <mi******@intercall.comschreef in bericht
news:u0**************@TK2MSFTNGP02.phx.gbl...
>I am creating a System.Windows.Forms.Form derived form in an OnClick()
method of a button. I would like to set the position of this new form on
the window, but I can't figure out what method to call or property to set
to override where the Operating System places the window. Any brillian
ideas our there?

Thanks


Nov 13 '06 #2
For your own location:
using (Form f = new Form())
{
f.StartPosition = FormStartPosition.Manual;
f.Location = new Point(200, -20);
f.ShowDialog(); // or Show(), with or without an owner
}

To centre on the parent use StartPosition = CenterParent, lose the
Location line, and be sure to pass the parent form as the owner in
Show[Dialog](). In fact, do that anyway - it keeps things stacked
correctly ;-p

Marc

Nov 13 '06 #3
Exactly what was needed. I had found the Location property, but apparently
without StartPosition being set, it had no effect.

Many thanks.
"Marc Gravell" <ma**********@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
For your own location:
using (Form f = new Form())
{
f.StartPosition = FormStartPosition.Manual;
f.Location = new Point(200, -20);
f.ShowDialog(); // or Show(), with or without an owner
}

To centre on the parent use StartPosition = CenterParent, lose the
Location line, and be sure to pass the parent form as the owner in
Show[Dialog](). In fact, do that anyway - it keeps things stacked
correctly ;-p

Marc

Nov 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Bryan R. Meyer | last post by:
Hello Everyone, The problem of browser resizing has become an issue for me. While redesigning my webpage, I set the left and right margins to be auto so that my content would be centered. ...
3
by: Jonah Bishop | last post by:
I have a strange problem that I'm hoping someone can help me with. I want a footer at the bottom of my simple HTML page to span the entire width of the page. I'm not using floats, columns or any...
14
by: Harlan Messinger | last post by:
What am I not understanding about the definition of { position: absolute; }? "The box's position (and possibly size) is specified with the 'left', 'right', 'top', and 'bottom' properties. These...
6
by: Gustaf Liljegren | last post by:
Here's what I'm trying to achieve: 1. A <div>, centered on screen, 600px wide and 100px high, with a background-image (also 600 x 100). 2. Text (an <h1> element) positioned with precision inside...
6
by: rajek | last post by:
I posted a similar question yesterday, but didn't get an answer that resolved the issue. (Thanks to those who tried though.) The background: I've read in books and online that if you have one...
11
by: NS | last post by:
I am relativly new to css positioning and have a question regarding the display of a DHTML pop-up Here is the basic HTML I am using: <html> <head> <script language="JavaScript"> <!--
17
by: George Hester | last post by:
http://tinyurl.com/5uj6w The lower middle icon the "block" should not drop down when the mouse is over it. How can I stop that? Also the navigation divs both top and bottom should follow the...
20
by: Geoffrey H. Goldberg | last post by:
I have made a remote control window which opens from its parent. On loading, the remote is positioned relative to the screen using window.moveTo(x,y). What I would like to happen is the remote...
2
by: Rob R. Ainscough | last post by:
I'm slowly (very slowly) working my way thru the bizarre and sadistic world of control positioning in MultiViews (ASP 2.0). I came across this to help me explain (or attempt to anyway) why my web...
2
by: Mel | last post by:
I place items at absolute locations on my LONG window. When I scroll the window My Absolute is only relative to the Viewing Area and tends to move up as i scroll my window. Is this the normal...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.