473,734 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1204
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.yo u> wrote in message
news:%2******** ********@TK2MSF TNGP10.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.StartPositio n = FormStartPositi on.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.yo u> 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(ByVa l TheForm As Form)
' Centers the form on the screen.
Dim RecForm As Rectangle = Screen.GetBound s
(TheForm)
TheForm.Left = CInt((RecForm.W idth -
TheForm.Width) / 2)
TheForm.Top = CInt((RecForm.H eight -
TheForm.Height) / 2)
End Sub
Nov 20 '05 #5
* "Marc" <an*******@disc ussions.microso ft.com> scripsit:
Try This
CenterForm(ME)
''''''''''''''' '''''''''

Sub CenterForm(ByVa l TheForm As Form)
' Centers the form on the screen.
Dim RecForm As Rectangle = Screen.GetBound s
(TheForm)
TheForm.Left = CInt((RecForm.W idth -
TheForm.Width) / 2)
TheForm.Top = CInt((RecForm.H eight -
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
15031
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: 100 px;float: left">thumbnail 2</div> <div style="width: 100 px;float: left">thumbnail 3</div> </div>
15
13504
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 with float. But I can't center two side by side divs. If I float them and give them auto margins, the auto margins are ignored. If I wrap the two floated divs in another div, the two divs have no
13
1955
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 suggestions on the net without any luck. I have the code for the whole page below. I've taken out all the Mac specific code that I tried and didn't work. Centering is done by a separate <div> tag. If anyone knows how to get the scroll area to...
3
4736
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 ShowDialog method. I am having a similar problem and I found a thread that had the following code in the child form's Load event: Me.Location = New Point(( _ Me.MdiParent.ClientSize.Width - Me.Width) * 0.5,
4
1605
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, when creating the Masterpage, this is the generated html: <body> <form id="form1" runat="server"> <div>
0
1036
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 (StartPosition = CenterParent)
3
4209
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 top level <divthen I can place it with CSS attribute 'left:', but this is a fixed offset. Is it possible to have a <divcentered in the browser window? 2. Verticle centering in <div>
5
4824
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 doing this demo with tables. The main problems are the vertical centering of the info area, and of the text inside the squares.
0
1028
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 and to the right. And the size of the word window is bigger than the form window that I'm calculating against (the word window should be .9 as wide and .8 as high). I think it may have something to do with the target box resolution or font size...
1
2287
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 rows are centering their data. however, the row with three columns, each with images (myimages1-3) are not centering with the rest of the table. Any idea why? Thanks in advance!
0
8776
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.