dataset填充msflexgrid

Public Sub us_viewData(ByVal v_MSFGrid As MSFlexGrid, ByVal v_rs As ADODB.Recordset)
    '功能:填充msflexgrid控件
    '参数:要填充的msflexgrid控件v_msfgrid,数据集v_rs
    Dim i, j As Integer
    v_MSFGrid.cols = v_rs.Fields.count + 1
    v_MSFGrid.ColWidth(0) = 12 * 25 * 1
    For j = 0 To v_rs.Fields.count - 1
        v_MSFGrid.TextMatrix(0, j + 1) = v_rs.Fields(j).Name
    Next
    If v_rs.RecordCount > 0 Then
        v_rs.MoveFirst
        v_MSFGrid.rows = v_rs.RecordCount + 1
        For i = 0 To v_rs.RecordCount - 1
            For j = 0 To v_rs.Fields.count - 1
                v_MSFGrid.TextMatrix(i + 1, j + 1) = v_rs.Fields(j)
            Next
            v_rs.MoveNext
        Next
    End If
    For i = 1 To v_MSFGrid.cols - 1
        v_MSFGrid.ColAlignment(i) = 4
    Next i
    
End Sub

 

转载于:https://www.cnblogs.com/leebokeyuan/p/5586692.html

你可能感兴趣的:(dataset填充msflexgrid)