共用方式為


ControlPaint.DrawBorder 方法

定義

在按鈕樣式控制項上繪製框線。

多載

DrawBorder(Graphics, Rectangle, Color, ButtonBorderStyle)

使用指定的樣式和色彩,在指定的圖形表層和按鈕樣式控制項的指定範圍內繪製框線。

DrawBorder(Graphics, Rectangle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle)

使用指定的樣式、色彩和框線寬度,在指定的圖形介面和指定的範圍內,於按鈕樣式控制項上繪製框線。

DrawBorder(Graphics, Rectangle, Color, ButtonBorderStyle)

使用指定的樣式和色彩,在指定的圖形表層和按鈕樣式控制項的指定範圍內繪製框線。

public:
 static void DrawBorder(System::Drawing::Graphics ^ graphics, System::Drawing::Rectangle bounds, System::Drawing::Color color, System::Windows::Forms::ButtonBorderStyle style);
public static void DrawBorder (System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Drawing.Color color, System.Windows.Forms.ButtonBorderStyle style);
static member DrawBorder : System.Drawing.Graphics * System.Drawing.Rectangle * System.Drawing.Color * System.Windows.Forms.ButtonBorderStyle -> unit
Public Shared Sub DrawBorder (graphics As Graphics, bounds As Rectangle, color As Color, style As ButtonBorderStyle)

參數

graphics
Graphics

要在上面繪製的 Graphics

bounds
Rectangle

Rectangle,表示框線的大小。

color
Color

框線的 Color

style
ButtonBorderStyle

其中一個 ButtonBorderStyle 值,指定框線樣式。

範例

下列程式碼範例示範如何使用其中 DrawBorder3D 一種方法。 若要執行此範例,請將下列程式碼貼到匯入 和 System.Drawing 命名空間的表單 System.Windows.Forms 中。 請確定表單的事件 Paint 與此範例中的事件處理常式相關聯。

// Handle the Form's Paint event to draw a 3D three-dimensional 
// raised border just inside the border of the frame.
void Form1_Paint( Object^ /*sender*/, PaintEventArgs^ e )
{
   Rectangle borderRectangle = this->ClientRectangle;
   borderRectangle.Inflate(  -10, -10 );
   ControlPaint::DrawBorder3D( e->Graphics, borderRectangle, Border3DStyle::Raised );
}
// Handle the Form's Paint event to draw a 3D three-dimensional 
// raised border just inside the border of the frame.
private void Form1_Paint(object sender, PaintEventArgs e)
{

    Rectangle borderRectangle = this.ClientRectangle;
    borderRectangle.Inflate(-10, -10);
    ControlPaint.DrawBorder3D(e.Graphics, borderRectangle, 
        Border3DStyle.Raised);
}
' Handle the Form's Paint event to draw a 3D three-dimensional 
' raised border just inside the border of the frame.
Private Sub Form1_Paint(ByVal sender As Object, _
    ByVal e As PaintEventArgs) Handles MyBase.Paint

    Dim borderRectangle As Rectangle = Me.ClientRectangle
    borderRectangle.Inflate(-10, -10)
    ControlPaint.DrawBorder3D(e.Graphics, borderRectangle, _
        Border3DStyle.Raised)
End Sub

適用於

DrawBorder(Graphics, Rectangle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle, Color, Int32, ButtonBorderStyle)

使用指定的樣式、色彩和框線寬度,在指定的圖形介面和指定的範圍內,於按鈕樣式控制項上繪製框線。

public:
 static void DrawBorder(System::Drawing::Graphics ^ graphics, System::Drawing::Rectangle bounds, System::Drawing::Color leftColor, int leftWidth, System::Windows::Forms::ButtonBorderStyle leftStyle, System::Drawing::Color topColor, int topWidth, System::Windows::Forms::ButtonBorderStyle topStyle, System::Drawing::Color rightColor, int rightWidth, System::Windows::Forms::ButtonBorderStyle rightStyle, System::Drawing::Color bottomColor, int bottomWidth, System::Windows::Forms::ButtonBorderStyle bottomStyle);
public static void DrawBorder (System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Drawing.Color leftColor, int leftWidth, System.Windows.Forms.ButtonBorderStyle leftStyle, System.Drawing.Color topColor, int topWidth, System.Windows.Forms.ButtonBorderStyle topStyle, System.Drawing.Color rightColor, int rightWidth, System.Windows.Forms.ButtonBorderStyle rightStyle, System.Drawing.Color bottomColor, int bottomWidth, System.Windows.Forms.ButtonBorderStyle bottomStyle);
static member DrawBorder : System.Drawing.Graphics * System.Drawing.Rectangle * System.Drawing.Color * int * System.Windows.Forms.ButtonBorderStyle * System.Drawing.Color * int * System.Windows.Forms.ButtonBorderStyle * System.Drawing.Color * int * System.Windows.Forms.ButtonBorderStyle * System.Drawing.Color * int * System.Windows.Forms.ButtonBorderStyle -> unit
Public Shared Sub DrawBorder (graphics As Graphics, bounds As Rectangle, leftColor As Color, leftWidth As Integer, leftStyle As ButtonBorderStyle, topColor As Color, topWidth As Integer, topStyle As ButtonBorderStyle, rightColor As Color, rightWidth As Integer, rightStyle As ButtonBorderStyle, bottomColor As Color, bottomWidth As Integer, bottomStyle As ButtonBorderStyle)

參數

graphics
Graphics

要在上面繪製的 Graphics

bounds
Rectangle

Rectangle,表示框線的大小。

leftColor
Color

框線左邊的 Color

leftWidth
Int32

左框線的寬度。

leftStyle
ButtonBorderStyle

其中一個 ButtonBorderStyle 值,指定左框線的樣式。

topColor
Color

框線上方的 Color

topWidth
Int32

上框線的寬度。

topStyle
ButtonBorderStyle

其中一個 ButtonBorderStyle 值,指定上框線的樣式。

rightColor
Color

框線右邊的 Color

rightWidth
Int32

右框線的寬度。

rightStyle
ButtonBorderStyle

其中一個 ButtonBorderStyle 值,指定右框線的樣式。

bottomColor
Color

框線下方的 Color

bottomWidth
Int32

下框線的寬度。

bottomStyle
ButtonBorderStyle

其中一個 ButtonBorderStyle 值,指定底部框線的樣式。

範例

下列程式碼範例示範如何使用其中 DrawBorder3D 一種方法。 若要執行此範例,請將下列程式碼貼到匯入 和 System.Drawing 命名空間的表單 System.Windows.Forms 中。 請確定表單的事件 Paint 與此範例中的事件處理常式相關聯。

// Handle the Form's Paint event to draw a 3D three-dimensional 
// raised border just inside the border of the frame.
void Form1_Paint( Object^ /*sender*/, PaintEventArgs^ e )
{
   Rectangle borderRectangle = this->ClientRectangle;
   borderRectangle.Inflate(  -10, -10 );
   ControlPaint::DrawBorder3D( e->Graphics, borderRectangle, Border3DStyle::Raised );
}
// Handle the Form's Paint event to draw a 3D three-dimensional 
// raised border just inside the border of the frame.
private void Form1_Paint(object sender, PaintEventArgs e)
{

    Rectangle borderRectangle = this.ClientRectangle;
    borderRectangle.Inflate(-10, -10);
    ControlPaint.DrawBorder3D(e.Graphics, borderRectangle, 
        Border3DStyle.Raised);
}
' Handle the Form's Paint event to draw a 3D three-dimensional 
' raised border just inside the border of the frame.
Private Sub Form1_Paint(ByVal sender As Object, _
    ByVal e As PaintEventArgs) Handles MyBase.Paint

    Dim borderRectangle As Rectangle = Me.ClientRectangle
    borderRectangle.Inflate(-10, -10)
    ControlPaint.DrawBorder3D(e.Graphics, borderRectangle, _
        Border3DStyle.Raised)
End Sub

另請參閱

適用於