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.Windows.FormsSystem.Drawing 命名空间的窗体中。 确保窗体的事件 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.Windows.FormsSystem.Drawing 命名空间的窗体中。 确保窗体的事件 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

另请参阅

适用于