gridview LookUpEdit按行更改datasource
Private clone As DataView
Private Sub GridView1_ShownEditor(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.ShownEditor
Dim View As GridView = CType(sender, GridView)
If View.FocusedColumn.FieldName = "warID" AndAlso TypeOf View.ActiveEditor Is GridLookUpEdit Then
Dim edit As DevExpress.XtraEditors.GridLookUpEdit
Dim table As DataTable
Dim row As DataRow
edit = CType(View.ActiveEditor, DevExpress.XtraEditors.GridLookUpEdit)
table = CType(edit.Properties.DataSource, DataTable)
clone = New DataView(table)
row = View.GetDataRow(View.FocusedRowHandle)
clone.RowFilter = " matID = '" & row("matID").ToString() & "'"
edit.Properties.DataSource = clone
End If
End Sub
Private Sub GridView1_HiddenEditor(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.HiddenEditor
If Not clone Is Nothing Then
clone.Dispose()
clone = Nothing
End If
End Sub
Private Sub GridView1_ShownEditor(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.ShownEditor
Dim View As GridView = CType(sender, GridView)
If View.FocusedColumn.FieldName = "warID" AndAlso TypeOf View.ActiveEditor Is GridLookUpEdit Then
Dim edit As DevExpress.XtraEditors.GridLookUpEdit
Dim table As DataTable
Dim row As DataRow
edit = CType(View.ActiveEditor, DevExpress.XtraEditors.GridLookUpEdit)
table = CType(edit.Properties.DataSource, DataTable)
clone = New DataView(table)
row = View.GetDataRow(View.FocusedRowHandle)
clone.RowFilter = " matID = '" & row("matID").ToString() & "'"
edit.Properties.DataSource = clone
End If
End Sub
Private Sub GridView1_HiddenEditor(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.HiddenEditor
If Not clone Is Nothing Then
clone.Dispose()
clone = Nothing
End If
End Sub