473,405 Members | 2,344 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,405 software developers and data experts.

Centering a Form

In old Visual BASIC 6-days it was possible to set the Left and Top-property
of a Form and put it into the center of the screen by using the Screen.Left,
Screen.Width, Top and Height.

Where do I find those old properties in VB 2003.NET

// Peter
Nov 20 '05 #1
5 1181
me.Left, me.Top, etc.

You can also set the startup position of the form to centerscreen, or if you
are using showdialog, you can use the centerowner.

"peter hansen" <wo**@tell.you> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
In old Visual BASIC 6-days it was possible to set the Left and Top-property of a Form and put it into the center of the screen by using the Screen.Left, Screen.Width, Top and Height.

Where do I find those old properties in VB 2003.NET

// Peter

Nov 20 '05 #2
Cor
Hi peter

me.StartPosition = FormStartPosition.CenterScreen

I think this is even easier?

Cor
of a Form and put it into the center of the screen by using the Screen.Left, Screen.Width, Top and Height.

Where do I find those old properties in VB 2003.NET

Nov 20 '05 #3
* "peter hansen" <wo**@tell.you> scripsit:
In old Visual BASIC 6-days it was possible to set the Left and Top-property
of a Form and put it into the center of the screen by using the Screen.Left,
Screen.Width, Top and Height.


Set its 'StartPosition' property to 'CenterScreen' or call the form's
'CenterToScreen' method.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
-----Original Message-----
In old Visual BASIC 6-days it was possible to set the Left and Top-propertyof a Form and put it into the center of the screen by using the Screen.Left,Screen.Width, Top and Height.

Where do I find those old properties in VB 2003.NET

// Peter
.


Try This
CenterForm(ME)
''''''''''''''''''''''''

Sub CenterForm(ByVal TheForm As Form)
' Centers the form on the screen.
Dim RecForm As Rectangle = Screen.GetBounds
(TheForm)
TheForm.Left = CInt((RecForm.Width -
TheForm.Width) / 2)
TheForm.Top = CInt((RecForm.Height -
TheForm.Height) / 2)
End Sub
Nov 20 '05 #5
* "Marc" <an*******@discussions.microsoft.com> scripsit:
Try This
CenterForm(ME)
''''''''''''''''''''''''

Sub CenterForm(ByVal TheForm As Form)
' Centers the form on the screen.
Dim RecForm As Rectangle = Screen.GetBounds
(TheForm)
TheForm.Left = CInt((RecForm.Width -
TheForm.Width) / 2)
TheForm.Top = CInt((RecForm.Height -
TheForm.Height) / 2)
End Sub


Why do that if the functionality is already built in?

;-)

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6

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

Similar topics

11
by: Jeff Thies | last post by:
I have a series of blocks that are float left that I need centered on the page. <div class="center" align="center"> <div style="width: 100 px;float: left">thumbnail 1</div> <div style="width:...
15
by: red | last post by:
How do I center two side by side divs ? I've been writing css pages for a while but there's one thing tha still eludes me. I can center a div with margin auto. I can place two divs side by side...
13
by: Raffi | last post by:
Hi, We have an application that requires IE. We recently incorporated CSS scroll areas. The scroll fields are supposed to be centered. They are except for IE5 for the Mac. I have tried various...
3
by: Zack Sessions | last post by:
I am using VB.NET 2003. I have read the threads concerning the problem where the FormStartPosition of CenterParent is ignored if the form is displayed with the Show method as opposed to the...
4
by: Paolo | last post by:
I would like to have it so that my webpages, which are built using MasterPages, always appear in the center of the browser of the user, even if he resizes the browser window. As a starting point,...
0
by: mabond | last post by:
Hi I'm having a problem centering my child window within its parent. It is opening docked top left. Form properties as follows: frmMain (IsMdiContainer = true) frmPCASelection...
3
by: John Pote | last post by:
1. Horizontal centering a <divin browser window. The current trend seems to be to place page content in a fixed width area in the middle of the browser window. How is this achieved? If I use a...
5
by: Markus Ernst | last post by:
Hello This is a test example: http://www.markusernst.ch/anthracite/ http://www.markusernst.ch/anthracite/living_divani.html After googling and experimenting for several hours, I ended up...
0
by: Steve | last post by:
Hi... This code appears to work on the development box when centering and sizing a word application in front of the form that triggered the automation. But on the target boxes, it skews down...
1
by: =?Utf-8?B?ZnJhbmt5?= | last post by:
Hello, I've created a table that has two rows that are span across three columns. The third row has three columns, each with an image. The last row is also span accross three columns. The span...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.