473,698 Members | 2,426 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 1201
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
13500
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
1950
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
4733
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
1600
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
1034
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
4199
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
4821
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
1025
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
2284
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
8609
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
9166
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...
1
8899
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
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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
3
2007
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.