resultsetform.vb
来自「Microsoft Mobile Development Handbook的代码」· VB 代码 · 共 42 行
VB
42 行
Imports System.Data.SqlServerCe
Public Class ResultSetForm
Private ProductResultSet As MasterDetail.ProductResultSet
Private ProductCategoryResultSet As MasterDetail.ProductCategoryResultSet
Private Sub ResultSetForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: Delete this line of code to remove the default AutoFill for 'MasterDetail.ProductResultSet'.
'ProductResultSet = New MasterDetail.ProductResultSet
'ProductResultSet.Bind(Me.ProductResultSetBindingSource)
'TODO: Delete this line of code to remove the default AutoFill for 'MasterDetail.ProductCategoryResultSet'.
ProductCategoryResultSet = New MasterDetail.ProductCategoryResultSet
ProductCategoryResultSet.Bind(Me.ProductCategoryResultSetBindingSource)
SetProductResultSet()
End Sub
Private Sub SetProductResultSet()
' Find the ProductCategoryID of the selected record
Dim prodCatID As Integer = CType((CType(Me.ProductCategoryResultSetBindingSource.Current, RowView)).UpdatableRecord("ProductCategoryID"), Integer)
' Create new resultset using our 'custom' constructor
ProductResultSet = New MasterDetail.ProductResultSet(False)
' Filter on the index we created earlier, and only the
' required ProductCategoryID
ProductResultSet.Open("ProductCategoryID_idx", prodCatID, prodCatID)
' Bind the BindingSource
ProductResultSet.Bind(Me.ProductResultSetBindingSource)
End Sub
Private Sub ProductCategoryResultSetDataGrid_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductCategoryResultSetDataGrid.CurrentCellChanged
Dim oldRS As SqlCeResultSet = Me.ProductResultSet
' User has clicked on the grid
SetProductResultSet()
' Dispose of the redundant SqlCEResultSet
oldRS.Dispose()
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?