在项目中使用BriskDataGrid
首先必须建立一个Windows应用程序TestBriskDataGrid。
要在这个项目里使用BriskDataGrid控件必须先在项目里添加引用。做法如下:
在工具箱单击“我的用户控件”
在面板上右击,在选择“添加/移除项...”
在“自定义工具箱”对话框的.NET Framework组件单击“浏览...”按钮
选择General.Control.WinForm.dll文件
只勾选BriskDataGrid,把其他两个的对勾去掉
单击“确定”按钮
这时在我的用户控件里BriskDataGrid控件。
把briskDataGrid添加到窗体上,做法和其它控件一样。
接下来要填充数据集,如下:
Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
#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
Private components As System.ComponentModel.IContainer
Friend WithEvents BriskDataGrid As General.Control.WinForm.BriskDataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.BriskDataGrid = New General.Control.WinForm.BriskDataGrid
Me.SuspendLayout()
'
'BriskDataGrid
'
Me.BriskDataGrid.Dock = System.Windows.Forms.DockStyle.Top
Me.BriskDataGrid.Location = New System.Drawing.Point(0, 0)
Me.BriskDataGrid.Name = "BriskDataGrid"
Me.BriskDataGrid.Size = New System.Drawing.Size(292, 232)
Me.BriskDataGrid.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.BriskDataGrid)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private conn As OleDbConnection
Private dsHR As DataSet
Private adptEmployee As OleDbDataAdapter
Private adptDepartment As OleDbDataAdapter
Private Sub FillDataSet()
Dim strConn As String
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = ../hr.mdb"
Me.conn = New OleDbConnection(strConn)
Me.dsHR = New DataSet
Me.adptEmployee = New OleDbDataAdapter("SELECT * FROM employees", Me.conn)
Me.adptDepartment = New OleDbDataAdapter("SELECT * FROM departments", Me.conn)
Me.adptDepartment.Fill(Me.dsHR, "departments")
Me.adptEmployee.Fill(Me.dsHR, "employees")
End Sub
Private Sub InitBriskDataGrid()
Dim dvEmployee As New DataView(Me.dsHR.Tables("employees"))
Me.BriskDataGrid.SetDataBinding(dvEmployee)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.FillDataSet()
Me.InitBriskDataGrid()
End Sub
End Class
运行程序,表employees的数据就显示在数据BriskDataGrid里了。