Compartilhar via


ScreenOrientation Enumeration

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Specifies the angle of the orientation of the device screen that can be accessed by the ScreenOrientation property.

Namespace:  Microsoft.WindowsCE.Forms
Assembly:  Microsoft.WindowsCE.Forms (in Microsoft.WindowsCE.Forms.dll)

Syntax

'Declaration
Public Enumeration ScreenOrientation
'Usage
Dim instance As ScreenOrientation
public enum ScreenOrientation
public enum class ScreenOrientation
type ScreenOrientation

Members

Member name Description
Supported by the .NET Compact Framework Angle0 Specifies a portrait orientation at 0 degrees.
Supported by the .NET Compact Framework Angle90 Specifies an orientation at 90 degrees.
Supported by the .NET Compact Framework Angle180 Specifies a landscape orientation at 180 degrees.
Supported by the .NET Compact Framework Angle270 Specifies an orientation at 270 degrees.

Remarks

The default portrait orientation is at angle 0. Requires Pocket PC 2003 update.

Examples

The following code example shows how button clicks rotate the screen orientation through the ScreenOrientation enumeration. This code example is part of a larger example provided for the SystemSettings class.

' Each click event changes the screen orientation, as determined
' by the variable x, which increments from 0 to 3 and then back
' to 0. Four clicks cycle through the ScreenOrientation enumeration.
Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click

   Select Case x
      Case 0

         ' Pass a value for the ScreenOrientation enumeration
         ' to the SetOrientation method, defined below,
         ' and increment x so that the next button
         ' click rotates the screen orientation.
         SetOrientation(ScreenOrientation.Angle90)
         x += 1
      Case 1
         SetOrientation(ScreenOrientation.Angle180)
         x += 1
      Case 2
         SetOrientation(ScreenOrientation.Angle270)
         x += 1
      Case 3
         SetOrientation(ScreenOrientation.Angle0)
         x = 0
      Case Else
         SetOrientation(ScreenOrientation.Angle0)
         x = 0
   End Select
End Sub


' Set the orientation to a value of the
' ScreenOrienation enumeration and update the
' status bar with the current angle.
Private Sub SetOrientation(so As ScreenOrientation)
   ' Set the requested orientation.
   SystemSettings.ScreenOrientation = so

   Me.StatusBar1.Text = SystemSettings.ScreenOrientation.ToString()
End Sub

 // Each click event changes the screen orientation, as determined
 // by the variable x, which increments from 0 to 3 and then back
 // to 0. Four clicks cycle through the ScreenOrientation enumeration.

private void button1_Click(object sender, System.EventArgs e)
{

 switch(x)
 {
  case 0:

   // Pass a value for the ScreenOrientation enumeration
   // to the SetOrientation method, defined below,
   // and increment x so that the next button
   // click rotates the screen orientation.
   SetOrientation(ScreenOrientation.Angle90);
   x++;
   break;
  case 1:
   SetOrientation(ScreenOrientation.Angle180);
   x++;
   break;
  case 2:
   SetOrientation(ScreenOrientation.Angle270);
   x++;
   break;
  case 3:
   SetOrientation(ScreenOrientation.Angle0);
   x = 0;
   break;
  default:
   SetOrientation(ScreenOrientation.Angle0);
   x = 0;
   break;
 }
}

 // Set the orientation to a value of the
 // ScreenOrienation enumeration and update the
 // status bar with the current angle.
private void SetOrientation(ScreenOrientation so)
{
 // Set the requested orientation.

 SystemSettings.ScreenOrientation = so;

 this.statusBar1.Text = SystemSettings.ScreenOrientation.ToString();
}

Platforms

Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Compact Framework

Supported in: 3.5, 2.0

See Also

Reference

Microsoft.WindowsCE.Forms Namespace