Guys, please help me out to place form in screen

manasi

Member
Joined
Jul 19, 2006
Messages
15
Programming Experience
Beginner
Hi all !

I am very new to VB.NET. Here is a query concerning to display of windows form.

I have created a windows form having one component as BUTTON.
On the click event of that button, am gonna display another form . I want this new form to be actually displayed at the extreme right of our monitor screen. So is there any code for pixel adjustment for this form on the screen?

Or can we display a form within form (i.e nested form) itself? And, if so, is there any code for pixel adjustment of this inner form within main form?

Responses are always appreciable.

Thanks,
Manasi
 
Check out the screen class, is has a PrimaryScreen Property in which you can get the bounds of the screen...

VB.NET:
Dim i as integer = Screen.Primaryscreen.Bounds.Right

will return the right bounding edge of the current screen. The set your forms location to that value...

VB.NET:
YourForm.Location = New Point((i-yourform.width),the co-ordinates on the y-axis you want to display your form)

N.B You may also need to convert that point into screen co-ordinates, in which case you'll need to use the PointToScreen Method
 
The Screen class has all the information you need about your desktop. To position a form in the bottom right-hand corner you would have the StartPosition property to Manual and then do this:
VB.NET:
Dim workingArea As Rectangle = Screen.PrimaryScreen.WorkingArea

myForm.Location = New Point(workingArea.Width - myForm.Width, workingArea.Height - myForm.Height)
If a form is an MDI child form then you do basically the same thing but you use the form's parent control instead of the desktop:
VB.NET:
Dim workingArea As Rectangle = myForm.Parent.ClientRectangle

myForm.Location = New Point(workingArea.Width - myForm.Width, workingArea.Height - myForm.Height)
 
Please do not create duplicate threads in future. You had people answering in both threads withotu knowing about the other. Nothing annoys me more than to spend my time trying to provide a solution only to find the same information has already been provided in a duplicate thread. Please don't waste our time.
 
Agreed Jmcilhinney, it's can get a bit confusing for someone like me who replies to a thread, then see another one exactly the same, i think that i'm caught in some kind of time warp get myself in a right old state and end up having to go down the pub to sort myself out!!:D

bonus is manasi, that you've got to see two different ways of using the screen class there.
 
Back
Top