定制自己的DataGridView

前端之家收集整理的这篇文章主要介绍了定制自己的DataGridView前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

VB 2005 代码

1.创建一个类 如:MyDataGridView

2.在类的声明后面加入代码说明继承至什么东东...
Public Class MyDataGridView : Inherits System.Windows.Forms.DataGridView

3.从工具箱中拖控件至类的设计页,将自动生成以下代码
Private Sub InitializeComponent()
Me.DataGridView = New System.Windows.Forms.DataGridView
CType(Me.DataGridView,System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me,System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'DataGridView
'
Me.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
Me.DataGridView.Location = New System.Drawing.Point(0,0)
Me.DataGridView.Name = "DataGridView"
Me.DataGridView.RowTemplate.Height = 24
Me.DataGridView.Size = New System.Drawing.Size(240,150)
Me.DataGridView.TabIndex = 0
'
'MyDataGridView
'
Me.RowTemplate.Height = 24
CType(Me.DataGridView,System.ComponentModel.ISupportInitialize).EndInit()
CType(Me,System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

End Sub

Friend WithEvents DataGridView As System.Windows.Forms.DataGridView

4.重新DataGridView 的方法,等等...
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message,ByVal keyData As System.Windows.Forms.Keys) As Boolean

Select Case keyData Case Windows.Forms.Keys.Enter System.Windows.Forms.SendKeys.Send("{TAB}") Return True End Select End Function

猜你在找的VB相关文章