Click here to Skip to main content
15,905,008 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All,

I need to maximize a form but only by the screen's width and it has a fixed height. and also be positioned on topmost like a taskbar on top.

Can you help me? Thanks!
[no name] 19-Jul-12 22:55pm    
Okay so set the width to be the screen width. What is the issue?
Kenneth Haugland 19-Jul-12 22:58pm    
About the topmost, is it WPF or WinForms?
graciax8 19-Jul-12 22:58pm    
i cant find a working code..
Sergey Alexandrovich Kryukov 20-Jul-12 0:02am    
This statement is not informative.
graciax8 19-Jul-12 22:59pm    

This code should do the trick:
Private Sub Form1_Load(sender As Object, e As EventArgs)
    Me.Location = New Point(0, 0)
    Me.Width = Screen.PrimaryScreen.WorkingArea.Width
End Sub
Share this answer
You can specify how your controls grow to fill a form using their properties. If that's not good enough, you need to write code to position your controls. You can specify a min and max height property for the form, which, if they are the same, will stop people resizing the form.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900