设为首页 加入收藏 网站搜索 繁體中文 中国建站网 — 站长资源分享平台

datagridcolumnstyle重写,实现插入不同控件列体验

来源:网络收集 作者:佚名 时间:2007-04-26 00:49:02

最近谈论较多的就是Datagrid,特别新手最是郁闷为何没有更好的控件,来满足自已的需求。
其实通过重写可以达到很多不同的功能体验,在这里我们仅仅讨论关于datagridcolumnstyle重写的问题
==========================================
Power by: landlordh
Datatime: 2005-08-04
转载请注明出处,谢谢
==========================================
1。重写TextBox:

Public Class XP_TextBox
    Inherits System.Windows.Forms.TextBox


#Region " Windows "

    Public Sub New()
        MyBase.New()

        InitializeComponent()


    End Sub


    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows
    Private components As System.ComponentModel.IContainer


    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        '
        'TextBox
        '
        Me.EnableContextMenu = True
        Me.EnablePaste = True
        Me.Name = "TextBox"

    End Sub

#End Region

#Region " Variables "

    Private m_EnPaste As Boolean = True
    Private m_EnContextMenu As Boolean = True

#End Region

#Region " Property "

    Property EnablePaste() As Boolean
        Get
            Return m_EnPaste
        End Get
        Set(ByVal Value As Boolean)
            m_EnPaste = Value
            Me.Invalidate()
        End Set
    End Property

    Property EnableContextMenu() As Boolean
        Get
            Return m_EnContextMenu
        End Get
        Set(ByVal Value As Boolean)
            m_EnContextMenu = Value
            Me.Invalidate()
        End Set
    End Property

#End Region

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Select Case m.Msg
            Case &H302 'paste
                RaiseEvent PasteEvent()
                If Not m_EnPaste Then Return
            Case &H7B 'contextmenu
                If Not m_EnContextMenu Then Return
        End Select
        MyBase.WndProc(m)
    End Sub

    Public Event PasteEvent()

End Class

2。重写datagridcolumnstyle(重点介绍内容):

Imports System.Drawing
Imports System.Windows.Forms

Public NotInheritable Class DataGridTextBoxColumnStyle
    Inherits System.Windows.Forms.DataGridColumnStyle

#Region "Declare Property"

    Private WithEvents m_TextBox As New Landlord.Component.XP_TextBox

[1] [2] [3] [4] [5]  下一页

Tags:

  • 好的评价 如果您觉得好,就请您
      0%(0)
  • 差的评价 如果您觉得差,就请您
      0%(0)
  • 相关文章
    广告赞助

    文章随便看看 设计素材 建站学院 网页模板 视频教程

    网友评论

    共有 0 位网友发表了评论,得分 0 分,平均 0 分    查看完整评论

    用户名: 查看更多评论

    分 值:100分 85分 70分 55分 40分 25分 10分 1分

    内 容:

             通知管理员 验证码: