setting window size based on screen resolution of the system

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hai,
I am working with windows forms in vb.net. i want to adjust window(form)
size based on screen resolution of the system(Resolution is small and
large).Is it possible to change .tell me some possible answer

Regards
shilpa
 
You can use Screen class to get the screen resolution.
This sample is taken from MSDN:
' This method will adjust the size of the form to utilize
' the working area of the screen.

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

' Retrieve the working rectangle from the Screen class
' using the PrimaryScreen and the WorkingArea properties.
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea

' Set the size of the form slightly less than size of
' working rectangle.
Me.Size = New System.Drawing.Size(workingRectangle.Width - 10, _
workingRectangle.Height - 10)

' Set the location so the entire form is visible.
Me.Location = New System.Drawing.Point(5, 5)

End Sub
 
On my window i have a control datagrid,that size is not changing.we have to
resize datagrid also.how can we change datagrid size with window size so that
complete window will be visble with every control.
 
Please check Anchor property of DataGrid (Almost every WinForms UI controls
have this property). It assures that the distance between the datagrid's
edges and its container control's edges (e.g a Form) remains constant even
after you resize the container.
 
Back
Top