Control.SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) Metod

Definition

Utför arbetet med att ange de angivna gränserna för den här kontrollen.

protected:
 virtual void SetBoundsCore(int x, int y, int width, int height, System::Windows::Forms::BoundsSpecified specified);
protected virtual void SetBoundsCore(int x, int y, int width, int height, System.Windows.Forms.BoundsSpecified specified);
abstract member SetBoundsCore : int * int * int * int * System.Windows.Forms.BoundsSpecified -> unit
override this.SetBoundsCore : int * int * int * int * System.Windows.Forms.BoundsSpecified -> unit
Protected Overridable Sub SetBoundsCore (x As Integer, y As Integer, width As Integer, height As Integer, specified As BoundsSpecified)

Parametrar

x
Int32

Kontrollens nya Left egenskapsvärde.

y
Int32

Kontrollens nya Top egenskapsvärde.

width
Int32

Kontrollens nya Width egenskapsvärde.

height
Int32

Kontrollens nya Height egenskapsvärde.

specified
BoundsSpecified

En bitvis kombination av BoundsSpecified värdena.

Exempel

I följande kodexempel åsidosätts SetBoundsCore metoden för att säkerställa att kontrollen förblir en fast storlek. Det här exemplet kräver att du har en klass som antingen direkt eller indirekt härleds Control från klassen.

protected:
   virtual void SetBoundsCore( int x, int y, int width, int height, BoundsSpecified specified ) override
   {
      // Set a fixed height and width for the control.
      UserControl::SetBoundsCore( x, y, 150, 75, specified );
   }
protected override void SetBoundsCore(int x, int y, 
   int width, int height, BoundsSpecified specified)
{
   // Set a fixed height and width for the control.
   base.SetBoundsCore(x, y, 150, 75, specified);
}
Protected Overrides Sub SetBoundsCore(x As Integer, _
  y As Integer, width As Integer, _
  height As Integer, specified As BoundsSpecified)
   ' Set a fixed height and width for the control.
   MyBase.SetBoundsCore(x, y, 150, 75, specified)
End Sub

Kommentarer

Vanligtvis skickas de parametrar som motsvarar de gränser som inte ingår i parametern specified in med deras aktuella värden. Till exempel Heightkan egenskaperna Width , Xeller Y eller Location för egenskapen skickas in med en referens till den aktuella instansen av kontrollen. Men alla värden som skickas in respekteras och tillämpas på kontrollen.

Parametern boundsSpecified representerar elementen i kontrollerna Bounds som ändrats av ditt program. Om du till exempel ändrar Size kontrollen boundsSpecified är Size parametervärdet värdet BoundsSpecifiedför . Men om Size justeras som svar på den Dock egenskap som anges är boundsSpecifiedNone parametervärdet värdet BoundsSpecifiedför .

Note

På Windows Server 2003-system begränsas storleken på en Form av bildskärmens maximala pixelbredd och höjd.

Anteckningar till arvingar

När du åsidosättar SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) i en härledd klass måste du anropa basklassens SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) metod för att tvinga kontrollens gränser att ändras. Härledda klasser kan lägga till storleksbegränsningar för SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) metoden.

Gäller för

Se även