gridview LookUpEdit按行更改datasource

    Private clone As DataView

    
Private Sub GridView1_ShownEditor(ByVal sender As ObjectByVal 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 ObjectByVal e As System.EventArgs) Handles GridView1.HiddenEditor
        
If Not clone Is Nothing Then
            clone.Dispose()
            clone 
= Nothing
        
End If
    
End Sub

 

posted on 2010-04-27 16:00  笑看风云淡  阅读(640)  评论(0编辑  收藏  举报

导航