C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » VB.NET Syntax »

Dynamically align the Form in a screen based on users screen resolution


Posted Date: 21 Jul 2009    Resource Type: Code Snippets    Category: VB.NET Syntax
Author: Viji RAJKUMARMember Level: Diamond    
Rating: 1 out of 5Points: 10







 


The following VB.NET Code Snippet is used to dynamically align the form to the center of the window, based on the the end users screen resolution.



Sub Center_Form()


Dim maxwidth As Integer = Screen.PrimaryScreen.WorkingArea.Size.Width


Dim left As Integer


Dim top As Integer


'Remove 10% top part of window


Dim maxheight As Integer = Screen.PrimaryScreen.WorkingArea.Size.Height - Screen.PrimaryScreen.WorkingArea.Size.Height * 0.1


left = (maxwidth - Me.Width) / 2


top = ((maxheight - Me.Height) / 2)


Me.Location = New Point(left, top)


End Sub



Call the function Center_Form in the Form_Load event of the form.



Private Sub DataForm1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


'Center display


Center_Form()


End Sub





The following VB.NET Code Snippet is used to maximize the form.



Private Sub Maximize()


Me.WindowState = FormWindowState.Maximized


End Sub




The following VB.NET Code Snippet is used to minimize the form.


Private Sub Minimize()


Me.WindowState = FormWindowState.Minimized


End Sub




For more details, visit http://vijirajkumar.blogspot.com/2009/07/dynamically-align-form-in-screen-based.html



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Windows Form alignment  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Foreach Loop
Previous Resource: Asp.net using VB.net
Return to Discussion Resource Index
Post New Resource
Category: VB.NET Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use