WinForm Datagrid结构剖析(三)使用代码

时间:2010-03-15 12:19:05  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:bsp;     '----------------------------------------------------------------------       Private ReadOnly Property DataGridTableGridLineWidth() As Integer       Get       If Me.DataGridTableStyle.GridLineStyle = DataGridLineStyle.Solid Then
  正文: 接(三)类代码一文:(由于每篇文章的字数限制,不得不割开发,见谅!)
  
   '----------------------------------------------------------------------
  
   ' 辅助方法
  
   '----------------------------------------------------------------------
  
   Private ReadOnly Property DataGridTableGridLineWidth() As Integer
  
   Get
  
   If Me.DataGridTableStyle.GridLineStyle = DataGridLineStyle.Solid Then
  
   Return 1
  
   Else
  
   Return 0
  
   End If
  
   End Get
  
   End Property
  
   Private Sub EndEdit()
  
   InEdit = False
  
   Invalidate()
  
   End Sub
  
   Private Function GetText(ByVal Value As Object) As String
  
   If Value Is System.DBNull.Value Then Return NullText
  
   If Not Value Is Nothing Then
  
   Return Value.ToString
  
   Else
  
   Return String.Empty
  
   End If
  
   End Function
  
   Private Sub HideComboBox() ‘隐藏Combobox
  
   If Combo.Focused Then
  
   Me.DataGridTableStyle.DataGrid.Focus()
  
   End If
  
   Combo.Visible = False
  
   End Sub
  
   Private Sub RollBack()
  
   Combo.Text = OldVal
  
   End Sub
  
   Private Sub PaintText(ByVal g As Graphics, _
  
   ByVal Bounds As Rectangle, _
  
   ByVal Text As String, _
  
   ByVal AlignToRight As Boolean)
  
   Dim BackBrush As Brush = New SolidBrush(Me.DataGridTableStyle.BackColor)
  
   Dim ForeBrush As Brush = New SolidBrush(Me.DataGridTableStyle.ForeColor)
  
   PaintText(g, Bounds, Text, BackBrush, ForeBrush, AlignToRight)
  
   End Sub
  
   Private Sub PaintText(ByVal g As Graphics, _
  
   ByVal TextBounds As Rectangle, _
  
   ByVal Text As String, _
  
   ByVal BackBrush As Brush, _
  
   ByVal ForeBrush As Brush, _
  
   ByVal AlignToRight As Boolean)
  
   Dim Rect As Rectangle = TextBounds
  
   Dim RectF As RectangleF = RectF.op_Implicit(Rect) ' 转为RectangleF类型
  
   Dim Format As StringFormat = New StringFormat()
  
   If AlignToRight Then
  
   Format.FormatFlags = StringFormatFlags.DirectionRightToLeft
  
   End If
  
   Select Case Me.Alignment
  
   Case Is = HorizontalAlignment.Left
  
   Format.Alignment = StringAlignment.Near
  
   Case Is = HorizontalAlignment.Right
  
   Format.Alignment = StringAlignment.Far
"WinForm Datagrid结构剖析(三)使用代码"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/aspnet/13236.html

 1/4    1 2 3 4 下一页 尾页


关键字:

关于《WinForm Datagrid结构剖析(三)使用代码》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td