开发自己的Excell控件 转自Winfar

对于程序员特别是从事信息管理编程的程序员来说,报表打印是整个编程过程中最麻烦但又必须做的事情,我们常用的方法就是:
       
一、将数据库记录导出到Excell中;
       
二、用CrystalReportActiveReport等报表工具生成报表文件然后再在程序中调用;
       
三、直接打印窗体;

       
对于第一种方法网上有许多文章介绍了怎样将数据表记录导入到Excell中并怎样控件Excell单元格式以便做出合适的报表,但是这种方法也有许多不便之处,一是用户的计算机上必须安装Excell,这显然不现实(当然盗版的另当别论),二是Excell自带的是ActiveX控件,虽然.Net仍支持ActiveX控件,但这与.Net的发展趋势显然是不相符的。
       
对于第二种方法网上与CrystalReportActiveReport相关的资料很少,而且使用也相当复杂,怎么制作报表全凭程序员自己摸索。
       
对于第三种方法除非想证明自己是菜鸟,否则没有人会使用。

       
既然如此,我们可不可以利用.Net提供的强大功能自己开发类似于Excell的控件呢?其实要开发一个控件只要做两件事,其一是定义各种属性和方法,其二是根据各种属性绘制控件界面。
       
下面我们来分析一下Excell的结构,Excell呈现给我们的是一张二维结构的表格,每一行相当于数据表的一个记录,每一列相当于数据表的字段。但Excell的每个单元又有许多的格式控件单元的呈现方式,这就是Excell与别的表格控件如DataGrid不相同的地方,那么如何实现每个单元都有不同的呈现方式呢?

       
首先我们可以定义一个类名称假设为DataCell,这个类定义了各种属性比如:背景颜色、文本颜色、文本字体、对齐方式、文本折行、单元宽度、单元高度等等,然后我们定义一个Arraylist对象,名称假设为DataRow,一个DataRow加载适当数量的DataCell对象,这个DataRow对象就相当于Excell的一行记录。
       
第二步我们再定义一个Arraylist对象,名称假设为DataTable,每个DataTable又加载一定数量的DataRow,那么这个DataTable对象其实就是一个有一定数量记录的二维表格了,只是这个表格的单元都有不同的格式。
       
第三步就是绘制控件界面了,在这一步我们可以利用GraphicsDrawStringDrawLineDrawRectangle、强大功能,根据DataCell对象提供的不同格式任意绘制控件界面了。
       
笔者根据上面的思路编制了一个类似于Excell的控件,虽然功能不如Excell强大,但对付一般的报表是足足有余了,您不想试试吗?
       
主页地址: Http://www.winfarsoft.com/
       
下载地址:Http://wwww.winfarsoft.com/richcell.exe



下面给出一些代码
第一步:定义一个单元类,类中定义了许多的属性,至于属性的用途我想大家一看就知,我这里不再一一说明
Imports System.Drawing.Drawing2D
Public Class WinFar_Cell
   Public InitFlag As Boolean
   Public BorderStyle As WinFar_BorderStyle = WinFar_BorderStyle.Normal
   Public BackColor As Color = Color.White
   Public ForeColor As Color = Color.Black
   Public MergeFlag As Boolean = False
   Public MergeRows As Integer = 0
   Public MergeCols As Integer = 0
   Public MergeRowStep As Integer = 0
   Public MergeColStep As Integer = 0
   Public LeftLineStyle As WinFar_LineStyle = WinFar_LineStyle.None
   Public TopLineStyle As WinFar_LineStyle = WinFar_LineStyle.None
   Public RightLineStyle As WinFar_LineStyle = WinFar_LineStyle.None
   Public BottomLineStyle As WinFar_LineStyle = WinFar_LineStyle.None
   Public Image As Image = Nothing
   Public ImageAlignment As WinFar_Alignment = WinFar_Alignment.LeftCenter
   Public Font As Font = New Font(New FontFamily("宋体"), 10)
   Public ShowStyle As WinFar_ShowStyle = WinFar_ShowStyle.Normal
   Public MultiLineFlag As Boolean = False
   Public TextAlignment As WinFar_Alignment = WinFar_Alignment.CenterCenter
   Public TextStyle As WinFar_TextStyle = WinFar_TextStyle.Normal
   Public Text As String = ""
   Public LockFlag As Boolean = False
   Public LoadString As String = ""
   Public HyperLink As String = ""
   Public CalcExpress As String = ""
   Public CheckExpress As String = ""
End Class

第二步:定义一个类,继承System.Windows.Forms.Control,为什么要继承继承System.Windows.Forms.Control不从现有的控件中继承是因为只有这样才我们才能最大限度地控制控件。
Imports System.Drawing
Imports System.Drawing.Text
Imports System.Drawing.Drawing2D
Imports System.Collections
Imports System.ComponentModel
Public Class WinFar_DataSheet
'在构造函数中加载单元
Public Sub New(Optional ByVal Rows As Integer = 50, Optional ByVal Cols As Integer = 26)
   Dim I As Integer
   Dim J As Integer
   Rows = 1000
   M_Rows = Rows
   M_Cols = Cols
   InitProperty()
   M_DataTable = New ArrayList()
   For I = 0 To M_Rows - 1
      M_RowitemCollection.Add(M_InitRowitem)
      M_DataRow = New ArrayList()
      For J = 0 To M_Cols - 1
         If I = 0 Then
            M_ColitemCollection.Add(M_InitColitem)
         End If
         'Dim S_Cell As New WinFar_Cell()
         'S_Cell.InitFlag = True
         'M_DataRow.Add(S_Cell)

         M_DataRow.Add(M_InitCell)
      Next
      M_DataTable.Add(M_DataRow)
   Next
End Sub
<Description("初始化属性")> _
Public Sub InitProperty()
   M_Zoom = 1
   M_Password = ""
   M_GridVisibledFlag = True
   M_GridColor = Color.Black
   M_GridStyle = DashStyle.Dot
   M_SelectBackColor = Color.FromArgb(88, 148, 158, 168)
   M_SelectForeColor = Color.Black
   M_LockBackColor = Color.FromKnownColor(KnownColor.Control)
   M_LockForeColor = Color.Gray
   M_CalcBackColor = Color.Transparent
   M_CalcForeColor = Color.Green
   M_HyperLinkBackColor = Color.Transparent
   M_HyperLinkForeColor = Color.Black
   M_DefaultBackColor = Color.Transparent
   M_DefaultForeColor = Color.Black
   M_LineColor = Color.Black
   M_AccountCount = 10
   M_DecimalCount = 2
   M_InitCell = New WinFar_Cell()

   M_Fixed3DStyleFlag = True
   M_FixedForeColor = Color.Black
   M_FixedBackColor = Color.FromKnownColor(KnownColor.Control)
   '固定单元中深色颜色
   M_FixedDarkColor = GetDarkColor(M_FixedBackColor)
   '固定单元中中色颜色
   M_FixedMiddleColor = GetMiddleColor(M_FixedBackColor)
   '固定单元中浅色颜色
   M_FixedLightColor = GetLightColor(M_FixedBackColor)
   If M_Rows < 10000 Then
      M_FixedWidth = 35
   Else
      M_FixedWidth = 42
   End If
   M_FixedHeight = 26
   M_FixedTextStyle = WinFar_TextStyle.Raised3DStyle
   M_FixedFont = New Font(New FontFamily("宋体"), 10)
   M_FixedRows = 0
   M_FixedCols = 0

   M_DataTable = New ArrayList()                    '单元行集合,每一个元素是一个ArrayList类
   M_DataRow = New ArrayList()                      '单元列集合,每一个元素是一个WinFar_Cell类
   M_RowitemCollection = New ArrayList()                '每一行高度的集合
   M_ColitemCollection = New ArrayList()                '每一列宽度的集合
   M_Rowitem = New WinFar_Rowitem()
   M_Colitem = New WinFar_Colitem()
   M_InitRowitem = New WinFar_Rowitem()
   M_InitColitem = New WinFar_Colitem()

   M_Row = 0                                        '选择区域的最上行,也就是当前行
   M_Col = 0                                        '选择区域的最左列,也就是当前列
   M_EndRow = 0                                     '选择区域的最下行
   M_EndCol = 0                                     '选择区域的最右列
   M_TopRow = 0                                     '最上边可见行
   M_LeftCol = 0                                    '最左边可见列
   '
   M_CopyString = ""
   M_UndoOpenFlag = True
   M_UndoType = New Specialized.StringCollection()
   M_UndoTable = New ArrayList()
   M_RedoType = New Specialized.StringCollection()
   M_RedoTable = New ArrayList()
End Sub
'第三步:重载Control的OnPaint事件,利用OnPaint事件中参数E的Grahpics属性的各种属性和方法绘制控件界面。
Protected Overrides Sub OnPaint(ByVal E As PaintEventArgs)
   Dim I As Integer
   Dim J As Integer
   Dim S_Left As Integer                         '获取单元的Left
   Dim S_Top As Integer                          '获取单元的Top
   Dim S_Width As Integer                        '获取单元的Width
   Dim S_Height As Integer                       '获取单元的Height
   Dim S_Rect As Rectangle                       '当前单元的Rect
   Dim S_Pen As Pen                              '打印表格线的铅笔
   Dim S_StringFormat As New StringFormat()      '打印折行文本时对齐方式
   M_Rect = New Rectangle(M_BorderWidth, M_BorderWidth, ClientRectangle.Width - M_VScrollSize - 2 * M_BorderWidth, ClientRectangle.Height - M_HScrollSize - 2 * M_BorderWidth)
   M_DataSheet.Rect = M_Rect
   '
   '填充背景
   '
   Select Case M_BackStyle
      Case WinFar_BackStyle.BackColorStyle
         '填充颜色
         E.Graphics.FillRectangle(New SolidBrush(M_BackColor), M_Rect)
      Case WinFar_BackStyle.BackHatchStyle
         '填充底纹
         E.Graphics.FillRectangle(New HatchBrush(M_BackHatchStyle, M_BackHatchColor, M_BackColor), M_Rect)
      Case WinFar_BackStyle.BackGradientSingleStyle
         '填充渐变色
         Dim S_LinearGradientBrush As New LinearGradientBrush(M_Rect, M_BackGradientBeginColor, M_BackGradientEndColor, M_BackGradientAngle)
         Dim S_RelativeIntensities As Single() = {0.0F, M_BackGradientPercent, 1.0F}
         Dim S_RelativePositions As Single() = {0.0F, M_BackGradientPosition, 1.0F}
         Dim S_Blend As New Blend()
         S_Blend.Factors = S_RelativeIntensities
         S_Blend.Positions = S_RelativePositions
         S_LinearGradientBrush.Blend = S_Blend
         S_LinearGradientBrush.Blend = S_Blend
         E.Graphics.FillRectangle(S_LinearGradientBrush, M_Rect)
      Case WinFar_BackStyle.BackGradientDoubleStyle
         If M_BackGradientAngle = 0 Then
            '填充左右双向渐变色
            Dim S_LinearGradientBrush1 As New LinearGradientBrush(New Rectangle(M_Rect.X, M_Rect.Y, Convert.ToInt32(M_Rect.Width / 2), M_Rect.Height), M_BackGradientBeginColor, M_BackGradientEndColor, 0)
            Dim S_LinearGradientBrush2 As New LinearGradientBrush(New Rectangle(M_Rect.X + Convert.ToInt32(M_Rect.Width / 2), M_Rect.Y, M_Rect.Width - Convert.ToInt32(M_Rect.Width / 2), M_Rect.Height), M_BackGradientBeginColor, M_BackGradientEndColor, 180)
            Dim S_RelativeIntensities As Single() = {0.0F, M_BackGradientPercent, 1.0F}
            Dim S_RelativePositions As Single() = {0.0F, M_BackGradientPosition, 1.0F}
            Dim S_Blend As New Blend()
            S_Blend.Factors = S_RelativeIntensities
            S_Blend.Positions = S_RelativePositions
            S_LinearGradientBrush1.Blend = S_Blend
            S_LinearGradientBrush1.Blend = S_Blend
            S_LinearGradientBrush2.Blend = S_Blend
            S_LinearGradientBrush2.Blend = S_Blend
            E.Graphics.FillRectangle(S_LinearGradientBrush1, New Rectangle(M_Rect.X, M_Rect.Y, Convert.ToInt32(M_Rect.Width / 2), M_Rect.Height))
            E.Graphics.FillRectangle(S_LinearGradientBrush2, New Rectangle(M_Rect.X + Convert.ToInt32(M_Rect.Width / 2), M_Rect.Y, M_Rect.Width - Convert.ToInt32(M_Rect.Width / 2), M_Rect.Height))
            E.Graphics.DrawLine(New Pen(M_BackGradientEndColor), M_Rect.X + Convert.ToInt32(M_Rect.Width / 2), M_Rect.Y, M_Rect.X + Convert.ToInt32(M_Rect.Width / 2), M_Rect.Bottom)
         Else
            '填充上下双向渐变色
            Dim S_LinearGradientBrush1 As New LinearGradientBrush(New Rectangle(M_Rect.X, M_Rect.Y, M_Rect.Width, Convert.ToInt32(M_Rect.Height / 2)), M_BackGradientBeginColor, M_BackGradientEndColor, 90)
            Dim S_LinearGradientBrush2 As New LinearGradientBrush(New Rectangle(M_Rect.X, M_Rect.Y + Convert.ToInt32(M_Rect.Height / 2), M_Rect.Width, M_Rect.Height - Convert.ToInt32(M_Rect.Height / 2)), M_BackGradientBeginColor, M_BackGradientEndColor, 270)
            Dim S_RelativeIntensities As Single() = {0.0F, M_BackGradientPercent, 1.0F}
            Dim S_RelativePositions As Single() = {0.0F, M_BackGradientPosition, 1.0F}
            Dim S_Blend As New Blend()
            S_Blend.Factors = S_RelativeIntensities
            S_Blend.Positions = S_RelativePositions
            S_LinearGradientBrush1.Blend = S_Blend
            S_LinearGradientBrush1.Blend = S_Blend
            S_LinearGradientBrush2.Blend = S_Blend
            S_LinearGradientBrush2.Blend = S_Blend
            E.Graphics.FillRectangle(S_LinearGradientBrush1, New Rectangle(M_Rect.X, M_Rect.Y, M_Rect.Width, Convert.ToInt32(M_Rect.Height / 2)))
            E.Graphics.FillRectangle(S_LinearGradientBrush2, New Rectangle(M_Rect.X, M_Rect.Y + Convert.ToInt32(M_Rect.Height / 2), M_Rect.Width, M_Rect.Height - Convert.ToInt32(M_Rect.Height / 2)))
            E.Graphics.DrawLine(New Pen(M_BackGradientEndColor), M_Rect.X, M_Rect.Y + Convert.ToInt32(M_Rect.Height / 2), M_Rect.Right, M_Rect.Y + +Convert.ToInt32(M_Rect.Height / 2))
         End If
      Case WinFar_BackStyle.BackPathSideStyle
         Dim S_Path As New GraphicsPath()
         S_Path.AddRectangle(M_Rect)
         Dim S_PathGrBrush As New PathGradientBrush(S_Path)
         S_PathGrBrush.CenterColor = M_BackGradientBeginColor
         Dim S_EndColor() As Color = {M_BackGradientEndColor}
         S_PathGrBrush.SurroundColors = S_EndColor
         If M_BackGradientAngle = 0 Then
            S_PathGrBrush.CenterPoint = New PointF(M_Rect.X, M_Rect.Y + M_Rect.Height / 2)
         ElseIf M_BackGradientAngle = 45 Then
            S_PathGrBrush.CenterPoint = New PointF(M_Rect.X, M_Rect.Y)
         ElseIf M_BackGradientAngle = 90 Then
            S_PathGrBrush.CenterPoint = New PointF(M_Rect.X + M_Rect.Width / 2, M_Rect.Y)
         ElseIf M_BackGradientAngle = 135 Then
            S_PathGrBrush.CenterPoint = New PointF(M_Rect.Right, M_Rect.Y)
         ElseIf M_BackGradientAngle = 180 Then
            S_PathGrBrush.CenterPoint = New PointF(M_Rect.Right, M_Rect.Y + M_Rect.Height / 2)
         ElseIf M_BackGradientAngle = 225 Then
            S_PathGrBrush.CenterPoint = New PointF(M_Rect.Right, M_Rect.Bottom)
         ElseIf M_BackGradientAngle = 270 Then
            S_PathGrBrush.CenterPoint = New PointF(M_Rect.X + M_Rect.Width / 2, M_Rect.Bottom)
         ElseIf M_BackGradientAngle = 315 Then
            S_PathGrBrush.CenterPoint = New PointF(M_Rect.X, M_Rect.Bottom)
         Else
            S_PathGrBrush.CenterPoint = New PointF(M_Rect.X + (M_Rect.Right - M_Rect.X) / 2, M_Rect.Y + (M_Rect.Bottom - M_Rect.Y) / 2)
         End If
         E.Graphics.FillRectangle(S_PathGrBrush, M_Rect)
      Case WinFar_BackStyle.BackPathCenterStyle
         Dim S_Path As New GraphicsPath()
         S_Path.AddRectangle(M_Rect)
         Dim S_PathGrBrush As New PathGradientBrush(S_Path)
         S_PathGrBrush.CenterColor = M_BackGradientBeginColor
         Dim S_EndColor() As Color = {M_BackGradientEndColor}
         S_PathGrBrush.SurroundColors = S_EndColor
         S_PathGrBrush.CenterPoint = New PointF(M_Rect.X + (M_Rect.Right - M_Rect.X) / 2, M_Rect.Y + (M_Rect.Bottom - M_Rect.Y) / 2)
         E.Graphics.FillRectangle(S_PathGrBrush, M_Rect)
      Case WinFar_BackStyle.BackImageStyle
         '填充图象:图象平铺
         If Not M_BackImage Is Nothing Then
            E.Graphics.FillRectangle(New TextureBrush(M_BackImage), M_Rect)
         End If
   End Select
   '
   '绘制版权信息
   '
   S_StringFormat.Alignment = StringAlignment.Center
   S_StringFormat.LineAlignment = StringAlignment.Center
   E.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias
   E.Graphics.DrawString("Winfarsoft  Foxcell", New Font(New FontFamily("Times New Roman"), 32), New SolidBrush(Color.WhiteSmoke), New RectangleF(M_Rect.X, M_Rect.Y - 80, M_Rect.Width, M_Rect.Height), S_StringFormat)
   E.Graphics.DrawString("1992~2004", New Font(New FontFamily("Times New Roman"), 32), New SolidBrush(Color.WhiteSmoke), New RectangleF(M_Rect.X, M_Rect.Y, M_Rect.Width, M_Rect.Height), S_StringFormat)
   E.Graphics.DrawString("Copyright (C) LiangZhongQi", New Font(New FontFamily("Times New Roman"), 32), New SolidBrush(Color.WhiteSmoke), New RectangleF(M_Rect.X, M_Rect.Y + 80, M_Rect.Width, M_Rect.Height), S_StringFormat)
   E.Graphics.TextRenderingHint = TextRenderingHint.SystemDefault
   '
   '绘制表格单元
   '
   Dim S_FixedWidth As Integer
   Dim S_FixedHeight As Integer
   S_FixedHeight = M_Rect.Y + M_DataSheet.GetFixedHeight()
   S_FixedWidth = M_Rect.X + M_DataSheet.GetFixedWidth()
   If M_BorderStyle = WinFar_BorderStyle.BorderEmbossStyle Then
      If M_DataSheet.FixedRows > 0 Then
         M_DataSheet.DrawFixedCols(E.Graphics, 0, M_DataSheet.FixedRows - 1, M_Rect.Y + M_DataSheet.FixedHeight * M_DataSheet.Zoom, True)
         M_DataSheet.DrawCell(E.Graphics, 0, M_DataSheet.LeftCol, M_DataSheet.FixedRows - 1, M_DataSheet.Cols - 1, S_FixedWidth, M_Rect.Y + M_DataSheet.FixedHeight * M_DataSheet.Zoom, M_EditingFlag)
      End If
      If M_DataSheet.FixedCols > 0 Then
         M_DataSheet.DrawFixedRows(E.Graphics, 0, M_DataSheet.FixedCols - 1, M_Rect.X + M_DataSheet.FixedWidth * M_DataSheet.Zoom, True)
         M_DataSheet.DrawCell(E.Graphics, M_DataSheet.TopRow, 0, M_DataSheet.Rows - 1, M_DataSheet.FixedCols - 1, M_Rect.X + M_DataSheet.FixedWidth * M_DataSheet.Zoom, S_FixedHeight, M_EditingFlag)
      End If
      If M_DataSheet.FixedRows > 0 And M_DataSheet.FixedCols > 0 Then
         M_DataSheet.DrawCell(E.Graphics, 0, 0, M_DataSheet.FixedRows - 1, M_DataSheet.FixedCols - 1, M_Rect.X + M_DataSheet.FixedWidth * M_DataSheet.Zoom, M_Rect.Y + M_DataSheet.FixedHeight * M_DataSheet.Zoom, M_EditingFlag)
      End If
      '
      '绘制非固定单元
      '
      M_DataSheet.DrawCell(E.Graphics, M_DataSheet.TopRow, M_DataSheet.LeftCol, M_DataSheet.Rows - 1, M_DataSheet.Cols - 1, S_FixedWidth, S_FixedHeight, M_EditingFlag)
      '
      '绘制表头单元
      '
      If M_DataSheet.FixedWidth > 0 Then
         M_DataSheet.DrawFixedCols(E.Graphics, M_DataSheet.TopRow, M_DataSheet.Rows - 1, S_FixedHeight, True)
      End If
      If M_DataSheet.FixedHeight > 0 Then
         M_DataSheet.DrawFixedRows(E.Graphics, M_DataSheet.LeftCol, M_DataSheet.Cols - 1, S_FixedWidth, True)
      End If
      If M_DataSheet.FixedWidth > 0 And M_DataSheet.FixedHeight > 0 Then
         M_DataSheet.DrawConner(E.Graphics, True)
      End If
   Else
      '绘制上边固定单元
      If M_DataSheet.FixedRows > 0 Then
         M_DataSheet.DrawFixedCols(E.Graphics, 0, M_DataSheet.FixedRows - 1, M_Rect.Y + M_DataSheet.FixedHeight * M_DataSheet.Zoom, False)
         M_DataSheet.DrawCell(E.Graphics, 0, M_DataSheet.LeftCol, M_DataSheet.FixedRows - 1, M_DataSheet.Cols - 1, S_FixedWidth, M_Rect.Y + M_DataSheet.FixedHeight * M_DataSheet.Zoom, M_EditingFlag)
      End If
      '绘制左边固定单元
      If M_DataSheet.FixedCols > 0 Then
         M_DataSheet.DrawFixedRows(E.Graphics, 0, M_DataSheet.FixedCols - 1, M_Rect.X + M_DataSheet.FixedWidth * M_DataSheet.Zoom, False)
         M_DataSheet.DrawCell(E.Graphics, M_DataSheet.TopRow, 0, M_DataSheet.Rows - 1, M_DataSheet.FixedCols - 1, M_Rect.X + M_DataSheet.FixedWidth * M_DataSheet.Zoom, S_FixedHeight, M_EditingFlag)
      End If
      '绘制左上角固定单元
      If M_DataSheet.FixedRows > 0 And M_DataSheet.FixedCols > 0 Then
         M_DataSheet.DrawCell(E.Graphics, 0, 0, M_DataSheet.FixedRows - 1, M_DataSheet.FixedCols - 1, M_Rect.X + M_DataSheet.FixedWidth * M_DataSheet.Zoom, M_Rect.Y + M_DataSheet.FixedHeight * M_DataSheet.Zoom, M_EditingFlag)
      End If
      '绘制右下角非固定单元
      M_DataSheet.DrawCell(E.Graphics, M_DataSheet.TopRow, M_DataSheet.LeftCol, M_DataSheet.Rows - 1, M_DataSheet.Cols - 1, S_FixedWidth, S_FixedHeight, M_EditingFlag)
      '
      '绘制表头单元
      '
      If M_DataSheet.FixedWidth > 0 Then
         M_DataSheet.DrawFixedCols(E.Graphics, M_DataSheet.TopRow, M_DataSheet.Rows - 1, S_FixedHeight, False)
      End If
      If M_DataSheet.FixedHeight > 0 Then
         M_DataSheet.DrawFixedRows(E.Graphics, M_DataSheet.LeftCol, M_DataSheet.Cols - 1, S_FixedWidth, False)
      End If
      If M_DataSheet.FixedWidth > 0 And M_DataSheet.FixedHeight > 0 Then
         M_DataSheet.DrawConner(E.Graphics, False)
      End If
   End If
   '
   '当鼠标移动时,画各种临时线或临时矩形
   '
   Select Case M_MouseState
      Case WinFar_MouseState.ResizeColing
         S_Pen = New Pen(Color.Gray)
         S_Pen.DashStyle = DashStyle.Dash
         E.Graphics.DrawLine(S_Pen, M_RBPoint.X, 0, M_RBPoint.X, Me.Height)
      Case WinFar_MouseState.ResizeRowing
         S_Pen = New Pen(Color.Gray)
         S_Pen.DashStyle = DashStyle.Dash
         E.Graphics.DrawLine(S_Pen, 0, M_RBPoint.Y, Me.Width, M_RBPoint.Y)
      Case WinFar_MouseState.DrawLineing
         If Math.Abs(M_RBPoint.X - M_LTPoint.X) > Math.Abs(M_RBPoint.Y - M_LTPoint.Y) Then
            E.Graphics.DrawLine(New Pen(Color.Blue, 3), M_LTPoint, New Point(M_RBPoint.X, M_LTPoint.Y))
         Else
            E.Graphics.DrawLine(New Pen(Color.Blue, 3), M_LTPoint, New Point(M_LTPoint.X, M_RBPoint.Y))
         End If
      Case WinFar_MouseState.DeleLineing
         If Math.Abs(M_RBPoint.X - M_LTPoint.X) > Math.Abs(M_RBPoint.Y - M_LTPoint.Y) Then
            E.Graphics.DrawLine(New Pen(Color.Red, 3), M_LTPoint, New Point(M_RBPoint.X, M_LTPoint.Y))
         Else
            E.Graphics.DrawLine(New Pen(Color.Red, 3), M_LTPoint, New Point(M_LTPoint.X, M_RBPoint.Y))
         End If
      Case WinFar_MouseState.MoveRowing
         M_DataSheet.DrawDragRow(E.Graphics, M_EndRow)
      Case WinFar_MouseState.MoveColing
         M_DataSheet.DrawDragCol(E.Graphics, M_EndCol)
      Case WinFar_MouseState.MoveCelling
         M_DataSheet.DrawDragCell(E.Graphics, M_EndRow, M_EndCol, M_DataSheet.EndRow - M_DataSheet.Row, M_DataSheet.EndCol - M_DataSheet.Col)
      Case WinFar_MouseState.CopyFormating
         '绘制来源单元边框
         S_Left = M_DataSheet.GetCellLeft(M_DataSheet.Col) + M_Rect.X
         S_Top = M_DataSheet.GetCellTop(M_DataSheet.Row) + M_Rect.Y
         S_Pen = New Pen(Color.Black)
         S_Pen.DashStyle = DashStyle.Dash
         S_Rect = New Rectangle(S_Left, S_Top, M_DataSheet.ColWidth(M_DataSheet.Col) * M_DataSheet.Zoom, M_DataSheet.RowHeight(M_DataSheet.Row) * M_DataSheet.Zoom)
         E.Graphics.DrawRectangle(New Pen(Color.White), S_Rect)
         E.Graphics.DrawRectangle(S_Pen, S_Rect)
         S_Rect = New Rectangle(S_Left + 1, S_Top + 1, M_DataSheet.ColWidth(M_DataSheet.Col) * M_DataSheet.Zoom - 2, M_DataSheet.RowHeight(M_DataSheet.Row) * M_DataSheet.Zoom - 2)
         E.Graphics.DrawRectangle(S_Pen, S_Rect)
         '绘制选择单元边框
         M_DataSheet.DrawDragCell(E.Graphics, M_Row, M_Col, M_EndRow - M_Row, M_EndCol - M_Col)
      Case WinFar_MouseState.DrawShapeing
         E.Graphics.DrawRectangle(New Pen(Color.Gray), M_LTPoint.X, M_LTPoint.Y, M_RBPoint.X - M_LTPoint.X, M_RBPoint.Y - M_LTPoint.Y)
      Case WinFar_MouseState.DrawCharting
         E.Graphics.DrawRectangle(New Pen(Color.Gray), M_LTPoint.X, M_LTPoint.Y, M_RBPoint.X - M_LTPoint.X, M_RBPoint.Y - M_LTPoint.Y)
   End Select
   '
   '绘制页标签栏
   '
   If M_DataLabelFlag = True Then
      '确定矩形并填充
      S_Rect = New Rectangle(M_BorderWidth, ClientRectangle.Bottom - M_BorderWidth - 18, ClientRectangle.Width - M_BorderWidth, 18)
      E.Graphics.FillRectangle(New HatchBrush(HatchStyle.Percent50, M_DataSheet.FixedBackColor, Color.White), S_Rect)
      '第一个按钮
      S_Rect = New Rectangle(M_BorderWidth, S_Rect.Top, 17, 18)
      M_DataSheet.DrawButton(E.Graphics, S_Rect, 1)
      '第二个按钮
      S_Rect = New Rectangle(S_Rect.Right + 1, S_Rect.Top, 17, 18)
      M_DataSheet.DrawButton(E.Graphics, S_Rect, 2)
      '第三个按钮
      S_Rect = New Rectangle(S_Rect.Right + 1, S_Rect.Top, 17, 18)
      M_DataSheet.DrawButton(E.Graphics, S_Rect, 3)
      '第四个按钮
      S_Rect = New Rectangle(S_Rect.Right + 1, S_Rect.Top, 17, 18)
      M_DataSheet.DrawButton(E.Graphics, S_Rect, 4)
      '
      '绘制标签
      '
      Dim S_Points(3) As PointF
      Dim S_Font As Font
      Dim S_LightColor As Color = M_DataSheet.GetLightColor(M_DataSheet.FixedBackColor)
      Dim S_DarkColor As Color = M_DataSheet.GetDarkColor(M_DataSheet.FixedBackColor)
      S_Font = New Font(New FontFamily("宋体"), 9)
      S_StringFormat.LineAlignment = StringAlignment.Center
      S_StringFormat.Alignment = StringAlignment.Center
      S_StringFormat.FormatFlags = StringFormatFlags.NoWrap
      S_Left = M_BorderWidth + 72
      For I = M_LeftMember To M_DataLabel.Count - 1
         S_Width = E.Graphics.MeasureString(M_DataLabel(I), S_Font).Width + 4
         S_Points(0) = New PointF(S_Left, ClientRectangle.Bottom - M_BorderWidth - 18)
         S_Points(1) = New PointF(S_Left + 17, ClientRectangle.Bottom - M_BorderWidth - 1)
         S_Points(2) = New PointF(S_Left + S_Width + 17, ClientRectangle.Bottom - M_BorderWidth - 1)
         S_Points(3) = New PointF(S_Left + S_Width + 17 + 17, ClientRectangle.Bottom - M_BorderWidth - 18)
         E.Graphics.FillPolygon(New SolidBrush(M_DataSheet.FixedBackColor), S_Points)
         E.Graphics.DrawPolygon(New Pen(Color.Black), S_Points)
         S_Rect = New Rectangle(S_Left + 17, ClientRectangle.Bottom - M_BorderWidth - 18, S_Width, 18)
         E.Graphics.DrawString(M_DataLabel(I), S_Font, New SolidBrush(Color.Black), New RectangleF(S_Rect.X + 2, S_Rect.Y + 2, S_Rect.Width, S_Rect.Height), S_StringFormat)
         S_Left = S_Left + S_Width + 17
         If M_Scrollbars = WinFar_Scrollbars.None Then
            If S_Left >= ClientRectangle.Width - M_BorderWidth Then
               Exit For
            End If
         ElseIf M_Scrollbars = WinFar_Scrollbars.Vertical Then
            If S_Left >= ClientRectangle.Width - M_HScrollSize - M_BorderWidth Then
               Exit For
            End If
         ElseIf M_Scrollbars = WinFar_Scrollbars.Horizontal Or M_Scrollbars = WinFar_Scrollbars.Both Then
            If S_Left >= ClientRectangle.Width * 0.75 Then
               Exit For
            End If
         End If
      Next
      '绘制当前标签
      S_Left = M_BorderWidth + 72
      For I = M_LeftMember To M_DataLabel.Count - 1
         S_Width = E.Graphics.MeasureString(M_DataLabel(I), S_Font).Width + 4
         If I = M_DataMember Then
            S_Points(0) = New PointF(S_Left, ClientRectangle.Bottom - M_BorderWidth - 18)
            S_Points(1) = New PointF(S_Left + 17, ClientRectangle.Bottom - M_BorderWidth - 1)
            S_Points(2) = New PointF(S_Left + S_Width + 17, ClientRectangle.Bottom - M_BorderWidth - 1)
            S_Points(3) = New PointF(S_Left + S_Width + 17 + 17, ClientRectangle.Bottom - M_BorderWidth - 18)
            E.Graphics.FillPolygon(New SolidBrush(S_LightColor), S_Points)
            E.Graphics.DrawPolygon(New Pen(Color.Black), S_Points)
            S_Rect = New Rectangle(S_Left + 17, ClientRectangle.Bottom - M_BorderWidth - 18, S_Width, 18)
            E.Graphics.DrawString(M_DataLabel(I), S_Font, New SolidBrush(Color.Black), New RectangleF(S_Rect.X + 2, S_Rect.Y + 2, S_Rect.Width, S_Rect.Height), S_StringFormat)
            Exit For
         End If
         S_Left = S_Left + S_Width + 17
      Next
      '
      '数据标签右边按钮
      '
      If M_Scrollbars = WinFar_Scrollbars.None Then
         S_Rect = New Rectangle(ClientRectangle.Width - M_BorderWidth - 7, S_Rect.Top, 6, 18)
      ElseIf M_Scrollbars = WinFar_Scrollbars.Vertical Then
         S_Rect = New Rectangle(ClientRectangle.Width - M_HScrollSize - M_BorderWidth - 7, S_Rect.Top, 6, 18)
      ElseIf M_Scrollbars = WinFar_Scrollbars.Horizontal Or M_Scrollbars = WinFar_Scrollbars.Both Then
         S_Rect = New Rectangle(ClientRectangle.Width * 0.75 - 7, S_Rect.Top, 6, 18)
      End If
      E.Graphics.FillRectangle(New SolidBrush(M_DataSheet.FixedBackColor), S_Rect)
      M_DataSheet.DrawButton(E.Graphics, S_Rect, 0)
   End If
   '
   '绘制右下角
   '
   If M_HScrollSize = 18 And M_VScrollSize = 18 Then
      E.Graphics.FillRectangle(New SolidBrush(Color.FromKnownColor(KnownColor.Control)), New Rectangle(ClientRectangle.Width - M_BorderWidth - 18, ClientRectangle.Height - M_BorderWidth - 18, 18, 18))
   End If
   '
   '绘制控件边框
   '
   Select Case BorderStyle
      Case WinFar_BorderStyle.BorderSingle
         E.Graphics.DrawRectangle(New Pen(Color.Black), New Rectangle(0, 0, ClientRectangle.Width - 1, ClientRectangle.Height - 1))
      Case WinFar_BorderStyle.BorderEmbossStyle
         '左
         E.Graphics.DrawLine(New Pen(M_DataSheet.GetDarkColor(M_DataSheet.FixedBackColor)), 0, 0, 0, ClientRectangle.Height)
         E.Graphics.DrawLine(New Pen(M_DataSheet.GetLightColor(M_DataSheet.FixedBackColor)), 1, 0, 1, ClientRectangle.Height)
         '上
         E.Graphics.DrawLine(New Pen(M_DataSheet.GetDarkColor(M_DataSheet.FixedBackColor)), 0, 0, ClientRectangle.Width, 0)
         E.Graphics.DrawLine(New Pen(M_DataSheet.GetLightColor(M_DataSheet.FixedBackColor)), 1, 1, ClientRectangle.Width, 1)
         '右
         E.Graphics.DrawLine(New Pen(Color.FromKnownColor(KnownColor.Control)), ClientRectangle.Width - 2, 1, ClientRectangle.Width - 2, ClientRectangle.Height - 3)
         E.Graphics.DrawLine(New Pen(Color.White), ClientRectangle.Width - 1, 0, ClientRectangle.Width - 1, ClientRectangle.Height - 1)
         '下
         E.Graphics.DrawLine(New Pen(Color.FromKnownColor(KnownColor.Control)), 1, ClientRectangle.Height - 2, ClientRectangle.Width - 2, ClientRectangle.Height - 2)
         E.Graphics.DrawLine(New Pen(Color.White), 0, ClientRectangle.Height - 1, ClientRectangle.Width - 1, ClientRectangle.Height - 1)
      Case WinFar_BorderStyle.BorderIn3DStyle, WinFar_BorderStyle.BorderOut3DStyle
         '上
         E.Graphics.DrawLine(New Pen(Color.Silver), 0, 0, ClientRectangle.Width, 0)
         E.Graphics.DrawLine(New Pen(Color.Black), 1, 1, ClientRectangle.Width, 1)
         'E.Graphics.DrawLine(New Pen(Color.Black), 1, 2, ClientRectangle.Width, 2)
         '左
         E.Graphics.DrawLine(New Pen(Color.Silver), 0, 0, 0, ClientRectangle.Height)
         E.Graphics.DrawLine(New Pen(Color.Black), 1, 1, 1, ClientRectangle.Height)
         'E.Graphics.DrawLine(New Pen(Color.Black), 2, 1, 2, ClientRectangle.Height)
         '下
         E.Graphics.DrawLine(New Pen(Color.FromKnownColor(KnownColor.Control)), 1, ClientRectangle.Height - 2, ClientRectangle.Width - 2, ClientRectangle.Height - 2)
         E.Graphics.DrawLine(New Pen(Color.White), 0, ClientRectangle.Height - 1, ClientRectangle.Width - 1, ClientRectangle.Height - 1)
         '右
         E.Graphics.DrawLine(New Pen(Color.FromKnownColor(KnownColor.Control)), ClientRectangle.Width - 2, 1, ClientRectangle.Width - 2, ClientRectangle.Height - 3)
         E.Graphics.DrawLine(New Pen(Color.White), ClientRectangle.Width - 1, 0, ClientRectangle.Width - 1, ClientRectangle.Height - 1)
   End Select
End Sub
End Class

至此控件完成了,当然上面的代码是不能执行的,因为这里只是提供一个思路,一个真正完整的控件还有许多事情要做。

如果各位有兴趣的话我们可以进行交流,共同探讨,共同提高。

在前一篇《开发自已的Excell控件》中没有相应的代码,在这里将给出一些代码
第一步:定义一个单元类,类中定义了许多的属性,至于属性的用途我想大家一看就知,我这里不再一一说明
Imports System.Drawing.Drawing2D
Public Class WinFar_Cell
Public InitFlag As Boolean
Public BorderStyle As WinFar_BorderStyle = WinFar_BorderStyle.Normal
Public BackColor As Color = Color.White
Public ForeColor As Color = Color.Black
Public MergeFlag As Boolean = False
Public MergeRows As Integer = 0
Public MergeCols As Integer = 0
Public MergeRowStep As Integer = 0
Public MergeColStep As Integer = 0
Public LeftLineStyle As WinFar_LineStyle = WinFar_LineStyle.None
Public TopLineStyle As WinFar_LineStyle = WinFar_LineStyle.None
Public RightLineStyle As WinFar_LineStyle = WinFar_LineStyle.None
Public BottomLineStyle As WinFar_LineStyle = WinFar_LineStyle.None
Public Image As Image = Nothing
Public ImageAlignment As WinFar_Alignment = WinFar_Alignment.LeftCenter
Public Font As Font = New Font(New FontFamily("宋体"), 10)
Public ShowStyle As WinFar_ShowStyle = WinFar_ShowStyle.Normal
Public MultiLineFlag As Boolean = False
Public TextAlignment As WinFar_Alignment = WinFar_Alignment.CenterCenter
Public TextStyle As WinFar_TextStyle = WinFar_TextStyle.Normal
Public Text As String = ""
Public LockFlag As Boolean = False
Public LoadString As String = ""
Public HyperLink As String = ""
Public CalcExpress As String = ""
Public CheckExpress As String = ""
End Class

第二步:定义一个类,继承System.Windows.Forms.Control,为什么要继承继

承System.Windows.Forms.Control不从现有的控件中继承是因为只有这样才我们才能最大限度地控制控件。
Imports System.Drawing
Imports System.Drawing.Text
Imports System.Drawing.Drawing2D
Imports System.Collections
Imports System.ComponentModel
Public Class WinFar_DataSheet
'在构造函数中加载单元
Public Sub New(Optional ByVal Rows As Integer = 50, Optional ByVal Cols As Integer = 26)
Dim I As Integer
Dim J As Integer
Rows = 1000
M_Rows = Rows
M_Cols = Cols
InitProperty()
M_DataTable = New ArrayList()
For I = 0 To M_Rows - 1
M_RowitemCollection.Add(M_InitRowitem)
M_DataRow = New ArrayList()
For J = 0 To M_Cols - 1
If I = 0 Then
M_ColitemCollection.Add(M_InitColitem)
End If
'Dim S_Cell As New WinFar_Cell()
'S_Cell.InitFlag = True
'M_DataRow.Add(S_Cell)

M_DataRow.Add(M_InitCell)
Next
M_DataTable.Add(M_DataRow)
Next
End Sub
<Description("初始化属性")> _
Public Sub InitProperty()
M_Zoom = 1
M_Password = ""
M_GridVisibledFlag = True
M_GridColor = Color.Black
M_GridStyle = DashStyle.Dot
M_SelectBackColor = Color.FromArgb(88, 148, 158, 168)
M_SelectForeColor = Color.Black
M_LockBackColor = Color.FromKnownColor(KnownColor.Control)
M_LockForeColor = Color.Gray
M_CalcBackColor = Color.Transparent
M_CalcForeColor = Color.Green
M_HyperLinkBackColor = Color.Transparent
M_HyperLinkForeColor = Color.Black
M_DefaultBackColor = Color.Transparent
M_DefaultForeColor = Color.Black
M_LineColor = Color.Black
M_AccountCount = 10
M_DecimalCount = 2
M_InitCell = New WinFar_Cell()

M_Fixed3DStyleFlag = True
M_FixedForeColor = Color.Black
M_FixedBackColor = Color.FromKnownColor(KnownColor.Control)
'固定单元中深色颜色
M_FixedDarkColor = GetDarkColor(M_FixedBackColor)
'固定单元中中色颜色
M_FixedMiddleColor = GetMiddleColor(M_FixedBackColor)
'固定单元中浅色颜色
M_FixedLightColor = GetLightColor(M_FixedBackColor)
If M_Rows < 10000 Then
M_FixedWidth = 35
Else
M_FixedWidth = 42
End If
M_FixedHeight = 26
M_FixedTextStyle = WinFar_TextStyle.Raised3DStyle
M_FixedFont = New Font(New FontFamily("宋体"), 10)
M_FixedRows = 0
M_FixedCols = 0

M_DataTable = New ArrayList() '单元行集合,每一个元素是一个ArrayList类
M_DataRow = New ArrayList() '单元列集合,每一个元素是一个WinFar_Cell类
M_RowitemCollection = New ArrayList() '每一行高度的集合
M_ColitemCollection = New ArrayList() '每一列宽度的集合
M_Rowitem = New WinFar_Rowitem()
M_Colitem = New WinFar_Colitem()
M_InitRowitem = New WinFar_Rowitem()
M_InitColitem = New WinFar_Colitem()

M_Row = 0 '选择区域的最上行,也就是当前行
M_Col = 0 '选择区域的最左列,也就是当前列
M_EndRow = 0 '选择区域的最下行
M_EndCol = 0 '选择区域的最右列
M_TopRow = 0 '最上边可见行
M_LeftCol = 0 '最左边可见列
'
M_CopyString = ""
M_UndoOpenFlag = True
M_UndoType = New Specialized.StringCollection()
M_UndoTable = New ArrayList()
M_RedoType = New Specialized.StringCollection()
M_RedoTable = New ArrayList()
End Sub
'第三步:重载Control的OnPaint事件,利用OnPaint事件中参数E的Grahpics属性的各种属性和方法绘制控件

界面。
Protected Overrides Sub OnPaint(ByVal E As PaintEventArgs)
Dim I As Integer
Dim J As Integer
Dim S_Left As Integer '获取单元的Left
Dim S_Top As Integer '获取单元的Top
Dim S_Width As Integer '获取单元的Width
Dim S_Height As Integer '获取单元的Height
Dim S_Rect As Rectangle '当前单元的Rect
Dim S_Pen As Pen '打印表格线的铅笔
Dim S_StringFormat As New StringFormat() '打印折行文本时对齐方式
M_Rect = New Rectangle(M_BorderWidth, M_BorderWidth, ClientRectangle.Width - M_VScrollSize -

2 * M_BorderWidth, ClientRectangle.Height - M_HScrollSize - 2 * M_BorderWidth)
M_DataSheet.Rect = M_Rect
'
'填充背景
'
Select Case M_BackStyle
Case WinFar_BackStyle.BackColorStyle
'填充颜色
E.Graphics.FillRectangle(New SolidBrush(M_BackColor), M_Rect)
Case WinFar_BackStyle.BackHatchStyle
'填充底纹
E.Graphics.FillRectangle(New HatchBrush(M_BackHatchStyle, M_BackHatchColor,

M_BackColor), M_Rect)
Case WinFar_BackStyle.BackGradientSingleStyle
'填充渐变色
Dim S_LinearGradientBrush As New LinearGradientBrush(M_Rect, M_BackGradientBeginColor,

M_BackGradientEndColor, M_BackGradientAngle)
Dim S_RelativeIntensities As Single() = {0.0F, M_BackGradientPercent, 1.0F}
Dim S_RelativePositions As Single() = {0.0F, M_BackGradientPosition, 1.0F}
Dim S_Blend As New Blend()
S_Blend.Factors = S_RelativeIntensities
S_Blend.Positions = S_RelativePositions
S_LinearGradientBrush.Blend = S_Blend
S_LinearGradientBrush.Blend = S_Blend
E.Graphics.FillRectangle(S_LinearGradientBrush, M_Rect)
Case WinFar_BackStyle.BackGradientDoubleStyle
If M_BackGradientAngle = 0 Then
'填充左右双向渐变色
Dim S_LinearGradientBrush1 As New LinearGradientBrush(New Rectangle(M_Rect.X,

M_Rect.Y, Convert.ToInt32(M_Rect.Width / 2), M_Rect.Height), M_BackGradientBeginColor,

M_BackGradientEndColor, 0)
Dim S_LinearGradientBrush2 As New LinearGradientBrush(New Rectangle(M_Rect.X +

Convert.ToInt32(M_Rect.Width / 2), M_Rect.Y, M_Rect.Width - Convert.ToInt32(M_Rect.Width / 2),

M_Rect.Height), M_BackGradientBeginColor, M_BackGradientEndColor, 180)
Dim S_RelativeIntensities As Single() = {0.0F, M_BackGradientPercent, 1.0F}
Dim S_RelativePositions As Single() = {0.0F, M_BackGradientPosition, 1.0F}
Dim S_Blend As New Blend()
S_Blend.Factors = S_RelativeIntensities
S_Blend.Positions = S_RelativePositions
S_LinearGradientBrush1.Blend = S_Blend
S_LinearGradientBrush1.Blend = S_Blend
S_LinearGradientBrush2.Blend = S_Blend
S_LinearGradientBrush2.Blend = S_Blend
E.Graphics.FillRectangle(S_LinearGradientBrush1, New Rectangle(M_Rect.X, M_Rect.Y,

Convert.ToInt32(M_Rect.Width / 2), M_Rect.Height))
E.Graphics.FillRectangle(S_LinearGradientBrush2, New Rectangle(M_Rect.X +

Convert.ToInt32(M_Rect.Width / 2), M_Rect.Y, M_Rect.Width - Convert.ToInt32(M_Rect.Width / 2),

M_Rect.Height))
E.Graphics.DrawLine(New Pen(M_BackGradientEndColor), M_Rect.X +

Convert.ToInt32(M_Rect.Width / 2), M_Rect.Y, M_Rect.X + Convert.ToInt32(M_Rect.Width / 2),

M_Rect.Bottom)
Else
'填充上下双向渐变色
Dim S_LinearGradientBrush1 As New LinearGradientBrush(New Rectangle(M_Rect.X,

M_Rect.Y, M_Rect.Width, Convert.ToInt32(M_Rect.Height / 2)), M_BackGradientBeginColor,

M_BackGradientEndColor, 90)
Dim S_LinearGradientBrush2 As New LinearGradientBrush(New Rectangle(M_Rect.X,

M_Rect.Y + Convert.ToInt32(M_Rect.Height / 2), M_Rect.Width, M_Rect.Height -

Convert.ToInt32(M_Rect.Height / 2)), M_BackGradientBeginColor, M_BackGradientEndColor, 270)
Dim S_RelativeIntensities As Single() = {0.0F, M_BackGradientPercent, 1.0F}
Dim S_RelativePositions As Single() = {0.0F, M_BackGradientPosition, 1.0F}
Dim S_Blend As New Blend()
S_Blend.Factors = S_RelativeIntensities
S_Blend.Positions = S_RelativePositions
S_LinearGradientBrush1.Blend = S_Blend
S_LinearGradientBrush1.Blend = S_Blend
S_LinearGradientBrush2.Blend = S_Blend
S_LinearGradientBrush2.Blend = S_Blend
E.Graphics.FillRectangle(S_LinearGradientBrush1, New Rectangle(M_Rect.X, M_Rect.Y,

M_Rect.Width, Convert.ToInt32(M_Rect.Height / 2)))
E.Graphics.FillRectangle(S_LinearGradientBrush2, New Rectangle(M_Rect.X, M_Rect.Y +

Convert.ToInt32(M_Rect.Height / 2), M_Rect.Width, M_Rect.Height - Convert.ToInt32(M_Rect.Height

/ 2)))
E.Graphics.DrawLine(New Pen(M_BackGradientEndColor), M_Rect.X, M_Rect.Y +

Convert.ToInt32(M_Rect.Height / 2), M_Rect.Right, M_Rect.Y + +Convert.ToInt32(M_Rect.Height /

2))
End If
Case WinFar_BackStyle.BackPathSideStyle
Dim S_Path As New GraphicsPath()
S_Path.AddRectangle(M_Rect)
Dim S_PathGrBrush As New PathGradientBrush(S_Path)
S_PathGrBrush.CenterColor = M_BackGradientBeginColor
Dim S_EndColor() As Color = {M_BackGradientEndColor}
S_PathGrBrush.SurroundColors = S_EndColor
If M_BackGradientAngle = 0 Then
S_PathGrBrush.CenterPoint = New PointF(M_Rect.X, M_Rect.Y + M_Rect.Height / 2)
ElseIf M_BackGradientAngle = 45 Then
S_PathGrBrush.CenterPoint = New PointF(M_Rect.X, M_Rect.Y)
ElseIf M_BackGradientAngle = 90 Then
S_PathGrBrush.CenterPoint = New PointF(M_Rect.X + M_Rect.Width / 2, M_Rect.Y)
ElseIf M_BackGradientAngle = 135 Then
S_PathGrBrush.CenterPoint = New PointF(M_Rect.Right, M_Rect.Y)
ElseIf M_BackGradientAngle = 180 Then
S_PathGrBrush.CenterPoint = New PointF(M_Rect.Right, M_Rect.Y + M_Rect.Height / 2)
ElseIf M_BackGradientAngle = 225 Then
S_PathGrBrush.CenterPoint = New PointF(M_Rect.Right, M_Rect.Bottom)
ElseIf M_BackGradientAngle = 270 Then
S_PathGrBrush.CenterPoint = New PointF(M_Rect.X + M_Rect.Width / 2, M_Rect.Bottom)
ElseIf M_BackGradientAngle = 315 Then
S_PathGrBrush.CenterPoint = New PointF(M_Rect.X, M_Rect.Bottom)
Else
S_PathGrBrush.CenterPoint = New PointF(M_Rect.X + (M_Rect.Right - M_Rect.X) / 2,

M_Rect.Y + (M_Rect.Bottom - M_Rect.Y) / 2)
End If
E.Graphics.FillRectangle(S_PathGrBrush, M_Rect)
Case WinFar_BackStyle.BackPathCenterStyle
Dim S_Path As New GraphicsPath()
S_Path.AddRectangle(M_Rect)
Dim S_PathGrBrush As New PathGradientBrush(S_Path)
S_PathGrBrush.CenterColor = M_BackGradientBeginColor
Dim S_EndColor() As Color = {M_BackGradientEndColor}
S_PathGrBrush.SurroundColors = S_EndColor
S_PathGrBrush.CenterPoint = New PointF(M_Rect.X + (M_Rect.Right - M_Rect.X) / 2,

M_Rect.Y + (M_Rect.Bottom - M_Rect.Y) / 2)
E.Graphics.FillRectangle(S_PathGrBrush, M_Rect)
Case WinFar_BackStyle.BackImageStyle
'填充图象:图象平铺
If Not M_BackImage Is Nothing Then
E.Graphics.FillRectangle(New TextureBrush(M_BackImage), M_Rect)
End If
End Select
'
'绘制版权信息
'
S_StringFormat.Alignment = StringAlignment.Center
S_StringFormat.LineAlignment = StringAlignment.Center
E.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias
E.Graphics.DrawString("Winfarsoft Foxcell", New Font(New FontFamily("Times New Roman"), 32),

New SolidBrush(Color.WhiteSmoke), New RectangleF(M_Rect.X, M_Rect.Y - 80, M_Rect.Width,

M_Rect.Height), S_StringFormat)
E.Graphics.DrawString("1992~2004", New Font(New FontFamily("Times New Roman"), 32), New

SolidBrush(Color.WhiteSmoke), New RectangleF(M_Rect.X, M_Rect.Y, M_Rect.Width, M_Rect.Height),

S_StringFormat)
E.Graphics.DrawString("Copyright (C) LiangZhongQi", New Font(New FontFamily("Times New

Roman"), 32), New SolidBrush(Color.WhiteSmoke), New RectangleF(M_Rect.X, M_Rect.Y + 80,

M_Rect.Width, M_Rect.Height), S_StringFormat)
E.Graphics.TextRenderingHint = TextRenderingHint.SystemDefault
'
'绘制表格单元
'
Dim S_FixedWidth As Integer
Dim S_FixedHeight As Integer
S_FixedHeight = M_Rect.Y + M_DataSheet.GetFixedHeight()
S_FixedWidth = M_Rect.X + M_DataSheet.GetFixedWidth()
If M_BorderStyle = WinFar_BorderStyle.BorderEmbossStyle Then
If M_DataSheet.FixedRows > 0 Then
M_DataSheet.DrawFixedCols(E.Graphics, 0, M_DataSheet.FixedRows - 1, M_Rect.Y +

M_DataSheet.FixedHeight * M_DataSheet.Zoom, True)
M_DataSheet.DrawCell(E.Graphics, 0, M_DataSheet.LeftCol, M_DataSheet.FixedRows - 1,

M_DataSheet.Cols - 1, S_FixedWidth, M_Rect.Y + M_DataSheet.FixedHeight * M_DataSheet.Zoom,

M_EditingFlag)
End If
If M_DataSheet.FixedCols > 0 Then
M_DataSheet.DrawFixedRows(E.Graphics, 0, M_DataSheet.FixedCols - 1, M_Rect.X +

M_DataSheet.FixedWidth * M_DataSheet.Zoom, True)
M_DataSheet.DrawCell(E.Graphics, M_DataSheet.TopRow, 0, M_DataSheet.Rows - 1,

M_DataSheet.FixedCols - 1, M_Rect.X + M_DataSheet.FixedWidth * M_DataSheet.Zoom, S_FixedHeight,

M_EditingFlag)
End If
If M_DataSheet.FixedRows > 0 And M_DataSheet.FixedCols > 0 Then
M_DataSheet.DrawCell(E.Graphics, 0, 0, M_DataSheet.FixedRows - 1, M_DataSheet.FixedCols

- 1, M_Rect.X + M_DataSheet.FixedWidth * M_DataSheet.Zoom, M_Rect.Y + M_DataSheet.FixedHeight *

M_DataSheet.Zoom, M_EditingFlag)
End If
'
'绘制非固定单元
'
M_DataSheet.DrawCell(E.Graphics, M_DataSheet.TopRow, M_DataSheet.LeftCol, M_DataSheet.Rows

- 1, M_DataSheet.Cols - 1, S_FixedWidth, S_FixedHeight, M_EditingFlag)
'
'绘制表头单元
'
If M_DataSheet.FixedWidth > 0 Then
M_DataSheet.DrawFixedCols(E.Graphics, M_DataSheet.TopRow, M_DataSheet.Rows - 1,

S_FixedHeight, True)
End If
If M_DataSheet.FixedHeight > 0 Then
M_DataSheet.DrawFixedRows(E.Graphics, M_DataSheet.LeftCol, M_DataSheet.Cols - 1,

S_FixedWidth, True)
End If
If M_DataSheet.FixedWidth > 0 And M_DataSheet.FixedHeight > 0 Then
M_DataSheet.DrawConner(E.Graphics, True)
End If
Else
'绘制上边固定单元
If M_DataSheet.FixedRows > 0 Then
M_DataSheet.DrawFixedCols(E.Graphics, 0, M_DataSheet.FixedRows - 1, M_Rect.Y +

M_DataSheet.FixedHeight * M_DataSheet.Zoom, False)
M_DataSheet.DrawCell(E.Graphics, 0, M_DataSheet.LeftCol, M_DataSheet.FixedRows - 1,

M_DataSheet.Cols - 1, S_FixedWidth, M_Rect.Y + M_DataSheet.FixedHeight * M_DataSheet.Zoom,

M_EditingFlag)
End If
'绘制左边固定单元
If M_DataSheet.FixedCols > 0 Then
M_DataSheet.DrawFixedRows(E.Graphics, 0, M_DataSheet.FixedCols - 1, M_Rect.X +

M_DataSheet.FixedWidth * M_DataSheet.Zoom, False)
M_DataSheet.DrawCell(E.Graphics, M_DataSheet.TopRow, 0, M_DataSheet.Rows - 1,

M_DataSheet.FixedCols - 1, M_Rect.X + M_DataSheet.FixedWidth * M_DataSheet.Zoom, S_FixedHeight,

M_EditingFlag)
End If
'绘制左上角固定单元
If M_DataSheet.FixedRows > 0 And M_DataSheet.FixedCols > 0 Then
M_DataSheet.DrawCell(E.Graphics, 0, 0, M_DataSheet.FixedRows - 1, M_DataSheet.FixedCols

- 1, M_Rect.X + M_DataSheet.FixedWidth * M_DataSheet.Zoom, M_Rect.Y + M_DataSheet.FixedHeight *

M_DataSheet.Zoom, M_EditingFlag)
End If
'绘制右下角非固定单元
M_DataSheet.DrawCell(E.Graphics, M_DataSheet.TopRow, M_DataSheet.LeftCol, M_DataSheet.Rows

- 1, M_DataSheet.Cols - 1, S_FixedWidth, S_FixedHeight, M_EditingFlag)
'
'绘制表头单元
'
If M_DataSheet.FixedWidth > 0 Then
M_DataSheet.DrawFixedCols(E.Graphics, M_DataSheet.TopRow, M_DataSheet.Rows - 1,

S_FixedHeight, False)
End If
If M_DataSheet.FixedHeight > 0 Then
M_DataSheet.DrawFixedRows(E.Graphics, M_DataSheet.LeftCol, M_DataSheet.Cols - 1,

S_FixedWidth, False)
End If
If M_DataSheet.FixedWidth > 0 And M_DataSheet.FixedHeight > 0 Then
M_DataSheet.DrawConner(E.Graphics, False)
End If
End If
'
'当鼠标移动时,画各种临时线或临时矩形
'
Select Case M_MouseState
Case WinFar_MouseState.ResizeColing
S_Pen = New Pen(Color.Gray)
S_Pen.DashStyle = DashStyle.Dash
E.Graphics.DrawLine(S_Pen, M_RBPoint.X, 0, M_RBPoint.X, Me.Height)
Case WinFar_MouseState.ResizeRowing
S_Pen = New Pen(Color.Gray)
S_Pen.DashStyle = DashStyle.Dash
E.Graphics.DrawLine(S_Pen, 0, M_RBPoint.Y, Me.Width, M_RBPoint.Y)
Case WinFar_MouseState.DrawLineing
If Math.Abs(M_RBPoint.X - M_LTPoint.X) > Math.Abs(M_RBPoint.Y - M_LTPoint.Y) Then
E.Graphics.DrawLine(New Pen(Color.Blue, 3), M_LTPoint, New Point(M_RBPoint.X,

M_LTPoint.Y))
Else
E.Graphics.DrawLine(New Pen(Color.Blue, 3), M_LTPoint, New Point(M_LTPoint.X,

M_RBPoint.Y))
End If
Case WinFar_MouseState.DeleLineing
If Math.Abs(M_RBPoint.X - M_LTPoint.X) > Math.Abs(M_RBPoint.Y - M_LTPoint.Y) Then
E.Graphics.DrawLine(New Pen(Color.Red, 3), M_LTPoint, New Point(M_RBPoint.X,

M_LTPoint.Y))
Else
E.Graphics.DrawLine(New Pen(Color.Red, 3), M_LTPoint, New Point(M_LTPoint.X,

M_RBPoint.Y))
End If
Case WinFar_MouseState.MoveRowing
M_DataSheet.DrawDragRow(E.Graphics, M_EndRow)
Case WinFar_MouseState.MoveColing
M_DataSheet.DrawDragCol(E.Graphics, M_EndCol)
Case WinFar_MouseState.MoveCelling
M_DataSheet.DrawDragCell(E.Graphics, M_EndRow, M_EndCol, M_DataSheet.EndRow -

M_DataSheet.Row, M_DataSheet.EndCol - M_DataSheet.Col)
Case WinFar_MouseState.CopyFormating
'绘制来源单元边框
S_Left = M_DataSheet.GetCellLeft(M_DataSheet.Col) + M_Rect.X
S_Top = M_DataSheet.GetCellTop(M_DataSheet.Row) + M_Rect.Y
S_Pen = New Pen(Color.Black)
S_Pen.DashStyle = DashStyle.Dash
S_Rect = New Rectangle(S_Left, S_Top, M_DataSheet.ColWidth(M_DataSheet.Col) *

M_DataSheet.Zoom, M_DataSheet.RowHeight(M_DataSheet.Row) * M_DataSheet.Zoom)
E.Graphics.DrawRectangle(New Pen(Color.White), S_Rect)
E.Graphics.DrawRectangle(S_Pen, S_Rect)
S_Rect = New Rectangle(S_Left + 1, S_Top + 1, M_DataSheet.ColWidth(M_DataSheet.Col) *

M_DataSheet.Zoom - 2, M_DataSheet.RowHeight(M_DataSheet.Row) * M_DataSheet.Zoom - 2)
E.Graphics.DrawRectangle(S_Pen, S_Rect)
'绘制选择单元边框
M_DataSheet.DrawDragCell(E.Graphics, M_Row, M_Col, M_EndRow - M_Row, M_EndCol - M_Col)
Case WinFar_MouseState.DrawShapeing
E.Graphics.DrawRectangle(New Pen(Color.Gray), M_LTPoint.X, M_LTPoint.Y, M_RBPoint.X -

M_LTPoint.X, M_RBPoint.Y - M_LTPoint.Y)
Case WinFar_MouseState.DrawCharting
E.Graphics.DrawRectangle(New Pen(Color.Gray), M_LTPoint.X, M_LTPoint.Y, M_RBPoint.X -

M_LTPoint.X, M_RBPoint.Y - M_LTPoint.Y)
End Select
'
'绘制页标签栏
'
If M_DataLabelFlag = True Then
'确定矩形并填充
S_Rect = New Rectangle(M_BorderWidth, ClientRectangle.Bottom - M_BorderWidth - 18,

ClientRectangle.Width - M_BorderWidth, 18)
E.Graphics.FillRectangle(New HatchBrush(HatchStyle.Percent50, M_DataSheet.FixedBackColor,

Color.White), S_Rect)
'第一个按钮
S_Rect = New Rectangle(M_BorderWidth, S_Rect.Top, 17, 18)
M_DataSheet.DrawButton(E.Graphics, S_Rect, 1)
'第二个按钮
S_Rect = New Rectangle(S_Rect.Right + 1, S_Rect.Top, 17, 18)
M_DataSheet.DrawButton(E.Graphics, S_Rect, 2)
'第三个按钮
S_Rect = New Rectangle(S_Rect.Right + 1, S_Rect.Top, 17, 18)
M_DataSheet.DrawButton(E.Graphics, S_Rect, 3)
'第四个按钮
S_Rect = New Rectangle(S_Rect.Right + 1, S_Rect.Top, 17, 18)
M_DataSheet.DrawButton(E.Graphics, S_Rect, 4)
'
'绘制标签
'
Dim S_Points(3) As PointF
Dim S_Font As Font
Dim S_LightColor As Color = M_DataSheet.GetLightColor(M_DataSheet.FixedBackColor)
Dim S_DarkColor As Color = M_DataSheet.GetDarkColor(M_DataSheet.FixedBackColor)
S_Font = New Font(New FontFamily("宋体"), 9)
S_StringFormat.LineAlignment = StringAlignment.Center
S_StringFormat.Alignment = StringAlignment.Center
S_StringFormat.FormatFlags = StringFormatFlags.NoWrap
S_Left = M_BorderWidth + 72
For I = M_LeftMember To M_DataLabel.Count - 1
S_Width = E.Graphics.MeasureString(M_DataLabel(I), S_Font).Width + 4
S_Points(0) = New PointF(S_Left, ClientRectangle.Bottom - M_BorderWidth - 18)
S_Points(1) = New PointF(S_Left + 17, ClientRectangle.Bottom - M_BorderWidth - 1)
S_Points(2) = New PointF(S_Left + S_Width + 17, ClientRectangle.Bottom - M_BorderWidth

- 1)
S_Points(3) = New PointF(S_Left + S_Width + 17 + 17, ClientRectangle.Bottom -

M_BorderWidth - 18)
E.Graphics.FillPolygon(New SolidBrush(M_DataSheet.FixedBackColor), S_Points)
E.Graphics.DrawPolygon(New Pen(Color.Black), S_Points)
S_Rect = New Rectangle(S_Left + 17, ClientRectangle.Bottom - M_BorderWidth - 18,

S_Width, 18)
E.Graphics.DrawString(M_DataLabel(I), S_Font, New SolidBrush(Color.Black), New

RectangleF(S_Rect.X + 2, S_Rect.Y + 2, S_Rect.Width, S_Rect.Height), S_StringFormat)
S_Left = S_Left + S_Width + 17
If M_Scrollbars = WinFar_Scrollbars.None Then
If S_Left >= ClientRectangle.Width - M_BorderWidth Then
Exit For
End If
ElseIf M_Scrollbars = WinFar_Scrollbars.Vertical Then
If S_Left >= ClientRectangle.Width - M_HScrollSize - M_BorderWidth Then
Exit For
End If
ElseIf M_Scrollbars = WinFar_Scrollbars.Horizontal Or M_Scrollbars =

WinFar_Scrollbars.Both Then
If S_Left >= ClientRectangle.Width * 0.75 Then
Exit For
End If
End If
Next
'绘制当前标签
S_Left = M_BorderWidth + 72
For I = M_LeftMember To M_DataLabel.Count - 1
S_Width = E.Graphics.MeasureString(M_DataLabel(I), S_Font).Width + 4
If I = M_DataMember Then
S_Points(0) = New PointF(S_Left, ClientRectangle.Bottom - M_BorderWidth - 18)
S_Points(1) = New PointF(S_Left + 17, ClientRectangle.Bottom - M_BorderWidth - 1)
S_Points(2) = New PointF(S_Left + S_Width + 17, ClientRectangle.Bottom -

M_BorderWidth - 1)
S_Points(3) = New PointF(S_Left + S_Width + 17 + 17, ClientRectangle.Bottom -

M_BorderWidth - 18)
E.Graphics.FillPolygon(New SolidBrush(S_LightColor), S_Points)
E.Graphics.DrawPolygon(New Pen(Color.Black), S_Points)
S_Rect = New Rectangle(S_Left + 17, ClientRectangle.Bottom - M_BorderWidth - 18,

S_Width, 18)
E.Graphics.DrawString(M_DataLabel(I), S_Font, New SolidBrush(Color.Black), New

RectangleF(S_Rect.X + 2, S_Rect.Y + 2, S_Rect.Width, S_Rect.Height), S_StringFormat)
Exit For
End If
S_Left = S_Left + S_Width + 17
Next
'
'数据标签右边按钮
'
If M_Scrollbars = WinFar_Scrollbars.None Then
S_Rect = New Rectangle(ClientRectangle.Width - M_BorderWidth - 7, S_Rect.Top, 6, 18)
ElseIf M_Scrollbars = WinFar_Scrollbars.Vertical Then
S_Rect = New Rectangle(ClientRectangle.Width - M_HScrollSize - M_BorderWidth - 7,

S_Rect.Top, 6, 18)
ElseIf M_Scrollbars = WinFar_Scrollbars.Horizontal Or M_Scrollbars =

WinFar_Scrollbars.Both Then
S_Rect = New Rectangle(ClientRectangle.Width * 0.75 - 7, S_Rect.Top, 6, 18)
End If
E.Graphics.FillRectangle(New SolidBrush(M_DataSheet.FixedBackColor), S_Rect)
M_DataSheet.DrawButton(E.Graphics, S_Rect, 0)
End If
'
'绘制右下角
'
If M_HScrollSize = 18 And M_VScrollSize = 18 Then
E.Graphics.FillRectangle(New SolidBrush(Color.FromKnownColor(KnownColor.Control)), New

Rectangle(ClientRectangle.Width - M_BorderWidth - 18, ClientRectangle.Height - M_BorderWidth -

18, 18, 18))
End If
'
'绘制控件边框
'
Select Case BorderStyle
Case WinFar_BorderStyle.BorderSingle
E.Graphics.DrawRectangle(New Pen(Color.Black), New Rectangle(0, 0,

ClientRectangle.Width - 1, ClientRectangle.Height - 1))
Case WinFar_BorderStyle.BorderEmbossStyle
'左
E.Graphics.DrawLine(New Pen(M_DataSheet.GetDarkColor(M_DataSheet.FixedBackColor)), 0,

0, 0, ClientRectangle.Height)
E.Graphics.DrawLine(New Pen(M_DataSheet.GetLightColor(M_DataSheet.FixedBackColor)), 1,

0, 1, ClientRectangle.Height)
'上
E.Graphics.DrawLine(New Pen(M_DataSheet.GetDarkColor(M_DataSheet.FixedBackColor)), 0,

0, ClientRectangle.Width, 0)
E.Graphics.DrawLine(New Pen(M_DataSheet.GetLightColor(M_DataSheet.FixedBackColor)), 1,

1, ClientRectangle.Width, 1)
'右
E.Graphics.DrawLine(New Pen(Color.FromKnownColor(KnownColor.Control)),

ClientRectangle.Width - 2, 1, ClientRectangle.Width - 2, ClientRectangle.Height - 3)
E.Graphics.DrawLine(New Pen(Color.White), ClientRectangle.Width - 1, 0,

ClientRectangle.Width - 1, ClientRectangle.Height - 1)
'下
E.Graphics.DrawLine(New Pen(Color.FromKnownColor(KnownColor.Control)), 1,

ClientRectangle.Height - 2, ClientRectangle.Width - 2, ClientRectangle.Height - 2)
E.Graphics.DrawLine(New Pen(Color.White), 0, ClientRectangle.Height - 1,

ClientRectangle.Width - 1, ClientRectangle.Height - 1)
Case WinFar_BorderStyle.BorderIn3DStyle, WinFar_BorderStyle.BorderOut3DStyle
'上
E.Graphics.DrawLine(New Pen(Color.Silver), 0, 0, ClientRectangle.Width, 0)
E.Graphics.DrawLine(New Pen(Color.Black), 1, 1, ClientRectangle.Width, 1)
'E.Graphics.DrawLine(New Pen(Color.Black), 1, 2, ClientRectangle.Width, 2)
'左
E.Graphics.DrawLine(New Pen(Color.Silver), 0, 0, 0, ClientRectangle.Height)
E.Graphics.DrawLine(New Pen(Color.Black), 1, 1, 1, ClientRectangle.Height)
'E.Graphics.DrawLine(New Pen(Color.Black), 2, 1, 2, ClientRectangle.Height)
'下
E.Graphics.DrawLine(New Pen(Color.FromKnownColor(KnownColor.Control)), 1,

ClientRectangle.Height - 2, ClientRectangle.Width - 2, ClientRectangle.Height - 2)
E.Graphics.DrawLine(New Pen(Color.White), 0, ClientRectangle.Height - 1,

ClientRectangle.Width - 1, ClientRectangle.Height - 1)
'右
E.Graphics.DrawLine(New Pen(Color.FromKnownColor(KnownColor.Control)),

ClientRectangle.Width - 2, 1, ClientRectangle.Width - 2, ClientRectangle.Height - 3)
E.Graphics.DrawLine(New Pen(Color.White), ClientRectangle.Width - 1, 0,

ClientRectangle.Width - 1, ClientRectangle.Height - 1)
End Select
End Sub
End Class

至此控件完成了,当然上面的代码是不能执行的,因为这里只是提供一个思路,一个真正完整的控件还有许多

事情要做。

如果各位有兴趣的话我们可以进行交流,共同探讨,共同提高。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值