DashStyle 枚举
指定用 Pen 对象绘制的虚线的样式。
**命名空间:**System.Drawing.Drawing2D
**程序集:**System.Drawing(在 system.drawing.dll 中)
语法
声明
Public Enumeration DashStyle
用法
Dim instance As DashStyle
public enum DashStyle
public enum class DashStyle
public enum DashStyle
public enum DashStyle
成员
成员名称 | 说明 | |
---|---|---|
Custom | 指定用户定义的自定义划线段样式。 | |
Dash | 指定由划线段组成的直线。 | |
DashDot | 指定由重复的划线点图案构成的直线。 | |
DashDotDot | 指定由重复的划线点点图案构成的直线。 | |
Dot | 指定由点构成的直线。 | |
Solid | 指定实线。 |
示例
下面的代码示例演示如何创建钢笔,以及如何使用 DashStyle 枚举设置其 DashStyle 属性。
此示例是针对使用 Windows 窗体而设计的。创建一个包含名为 Button3
的 Button 的窗体。将代码粘贴到该窗体中,并将 Button3_Click
方法与按钮的 Click 事件关联。
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
Dim buttonGraphics As Graphics = Button3.CreateGraphics()
Dim myPen As Pen = New Pen(Color.ForestGreen, 4.0F)
myPen.DashStyle = Drawing2D.DashStyle.DashDotDot
Dim theRectangle As Rectangle = Button3.ClientRectangle
theRectangle.Inflate(-2, -2)
buttonGraphics.DrawRectangle(myPen, theRectangle)
buttonGraphics.Dispose()
myPen.Dispose()
End Sub
private void Button3_Click(System.Object sender, System.EventArgs e)
{
Graphics buttonGraphics = Button3.CreateGraphics();
Pen myPen = new Pen(Color.ForestGreen, 4.0F);
myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
Rectangle theRectangle = Button3.ClientRectangle;
theRectangle.Inflate(-2, -2);
buttonGraphics.DrawRectangle(myPen, theRectangle);
buttonGraphics.Dispose();
myPen.Dispose();
}
private:
void Button3_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
Graphics^ buttonGraphics = Button3->CreateGraphics();
Pen^ myPen = gcnew Pen( Color::ForestGreen,4.0F );
myPen->DashStyle = System::Drawing::Drawing2D::DashStyle::DashDotDot;
Rectangle theRectangle = Button3->ClientRectangle;
theRectangle.Inflate( -2, -2 );
buttonGraphics->DrawRectangle( myPen, theRectangle );
delete buttonGraphics;
delete myPen;
}
private void button3_Click(Object sender, System.EventArgs e)
{
Graphics buttonGraphics = button3.CreateGraphics();
Pen myPen = new Pen(Color.get_ForestGreen(), 4.0F);
myPen.set_DashStyle(System.Drawing.Drawing2D.DashStyle.DashDotDot);
Rectangle theRectangle = button3.get_ClientRectangle();
theRectangle.Inflate(-2, -2);
buttonGraphics.DrawRectangle(myPen, theRectangle);
buttonGraphics.Dispose();
myPen.Dispose();
} //button3_Click
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0